New backend: magicolor (for KONICA MINOLTA magicolor devices)

-) LAN and USB communication
-) SNMP LAN auto-detection (using libsnmp, added configure check!)
-) Based on the epson2 backend, with many structural changes
-) B/W, Gray, Color scanning works in 150/300/600dpi (full-page
   color scan only possible with <=300dpi)

-) The timeouts (SNMP, scan data, other data) are configurable in the
   magicolor.conf file

-) Keeps list of known scanners in sane_get_devices, does not destroy
   existing handles; Also correctly calls sanei_usb_init.
merge-requests/1/head
Reinhold Kainhofer 2011-01-06 17:01:27 +01:00
rodzic d0097b0752
commit 6a7888ef26
13 zmienionych plików z 3391 dodań i 8 usunięć

Wyświetl plik

@ -57,6 +57,7 @@ Backends:
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
@ -223,6 +224,7 @@ Peter Kirchgessner <peter@kirchgessner.net>
Petter Reinholdtsen <pere@hungry.com>
Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
Randolph Bentson <bentson@grieg.holmsjoen.com>
Reinhold Kainhofer <reinhold@kainhofer.com>
Rene Rebe <rene@exactcode.de>
Roger Wolff <R.E.Wolff@BitWizard.nl>
Roy Zhou <Roy@mail.mustek-hz.com.cn>

Wyświetl plik

@ -1,6 +1,8 @@
2011-01-15 Reinhold Kainhofer <reinhold@kainhofer.com>
* sanei/sanei_usb.c: Add function sanei_usb_set_endpoint to change the
endpoints for usb communications.
* backend/magicolor.c: Add new "magicolor" backend for KONICA MINOLTA
magicolor 1690MF devices
2011-01-13 Stéphane Voltz <stef.dev@free.fr>
* backend/genesys_devices.c backend/genesys_gl124.c backend/genesys_gl124.h

Wyświetl plik

@ -86,8 +86,8 @@ BACKEND_CONFS= abaton.conf agfafocus.conf apple.conf artec.conf \
epson.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 \
leo.conf lexmark.conf ma1509.conf matsushita.conf \
microtek2.conf microtek.conf mustek.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 pixma.conf plustek.conf plustek_pp.conf \
@ -177,7 +177,7 @@ be_convenience_libs = libabaton.la libagfafocus.la \
libhp5400.la libhp5590.la libhpljm1005.la \
libhpsj5s.la libhs2p.la libibm.la libkodak.la \
libkvs1025.la libkvs20xx.la \
libleo.la liblexmark.la libma1509.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 \
@ -209,8 +209,8 @@ be_dlopen_libs = libsane-abaton.la libsane-agfafocus.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-kvs1025.la libsane-kvs20xx.la \
libsane-leo.la libsane-lexmark.la libsane-ma1509.la \
libsane-kvs1025.la libsane-kvs20xx.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 \
@ -667,6 +667,15 @@ 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
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)
EXTRA_DIST += magicolor.conf.in
libmatsushita_la_SOURCES = matsushita.c matsushita.h
libmatsushita_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=matsushita

Wyświetl plik

@ -44,6 +44,7 @@ kvs20xx
leo
lexmark
ma1509
magicolor
matsushita
microtek
microtek2

2927
backend/magicolor.c 100644

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,42 @@
### 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 2.5 seconds
snmp-timeout 2500
# 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 <vendor ID> <device ID> 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 <product ID> <device ID>
### e.g.:
# usb 0x132b 0x2098

233
backend/magicolor.h 100644
Wyświetl plik

@ -0,0 +1,233 @@
/*
* magicolor.h - SANE library for Magicolor scanners.
*
* (C) 2010 Reinhold Kainhofer <reinhold@kainhofer.com>
*
* 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 <a.zummo@towertech.it>
*
* 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 <sys/ioctl.h>
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef NEED_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <stdio.h>
#include "../include/sane/sane.h"
#include "../include/sane/sanei_debug.h"
#include "../include/sane/sanei_backend.h"
#ifdef __GNUC__
#define __func__ __FUNCTION__
#else
#define __func__ "(undef)"
/* I cast my vote for C99... :) */
#endif
/* Silence the compiler for unused arguments */
#define NOT_USED(x) ( (void)(x) )
#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

Wyświetl plik

@ -141,6 +141,51 @@ fi
dnl check sane to make sure we don't have two installations
AC_CHECK_LIB(sane, sane_init, LIBSANE_EXISTS="yes")
dnl **************************************************************
dnl SNMP CHECKS
dnl **************************************************************
AC_ARG_WITH(snmp,
AC_HELP_STRING([--without-snmp], [disable SNMP support]))
if test "$with_snmp" = "no"; then
echo "Not including SNMP support"
else
AC_PATH_PROG(SNMP_CONFIG_PATH, net-snmp-config, "no")
AC_CHECK_LIB([netsnmp], [snmp_timeout], LIBSNMP_EXISTS="yes")
AC_MSG_CHECKING(for proper SNMP version)
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 5005; then
SNMP_LIBS=`$SNMP_CONFIG_PATH --libs`
SNMP_CFLAGS=`$SNMP_CONFIG_PATH --cflags`
AC_MSG_RESULT(yes)
with_snmp="yes"
else
AC_MSG_RESULT(no)
AC_MSG_WARN([You need at least net-snmp 5.5, your version is $snmp_version])
with_snmp="no"
fi
else
with_snmp="no"
AC_MSG_RESULT(no)
fi
fi
if test "$with_snmp" = "yes"; then
LIBS="$LIBS $SNMP_LIBS"
CFLAGS="$CFLAGS $SNMP_CFLAGS"
AC_DEFINE([HAVE_LIBSNMP], [1], [net-snmp library is available])
else
AC_MSG_WARN([*** Warning: net-snmp library disabled, autodetecting network scanners will not be supported.])
fi
dnl ***********************************************************************
dnl Checks for header files.
dnl ***********************************************************************
@ -511,7 +556,7 @@ ALL_BACKENDS="abaton agfafocus apple artec artec_eplus48u as6e \
dell1600n_net dmc epjitsu epson epson2 fujitsu genesys \
gphoto2 gt68xx hp hp3500 hp3900 hp4200 hp5400 \
hp5590 hpsj5s hpljm1005 hs2p ibm kodak kvs1025 kvs20xx \
leo lexmark ma1509 \
leo lexmark ma1509 magicolor \
matsushita microtek microtek2 mustek mustek_pp \
mustek_usb mustek_usb2 nec net niash pie pint \
pixma plustek plustek_pp qcam ricoh rts8891 s9036 \
@ -705,6 +750,7 @@ else
fi
echo "IPv6 support: `eval eval echo ${ipv6}`"
echo "Avahi support: `eval eval echo ${enable_avahi}`"
echo "SNMP support: `eval eval echo ${with_snmp}`"
echo "-> The following backends will be built:"
for backend in ${BACKENDS} ; do
echo $ECHO_N "${backend} "

Wyświetl plik

@ -37,7 +37,7 @@ BACKEND_5MANS = sane-abaton.5 sane-agfafocus.5 sane-apple.5 sane-as6e.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-p5.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 \
@ -61,7 +61,8 @@ EXTRA_DIST += sane-abaton.man sane-agfafocus.man sane-apple.man sane-as6e.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-p5.man
sane-coolscan3.man sane-kvs1025.man sane-kvs20xx.man sane-p5.man \
sane-magicolor.man
man7_MANS = sane.7
EXTRA_DIST += sane.man
@ -175,6 +176,7 @@ DESC_FILES = descriptions/abaton.desc descriptions/agfafocus.desc \
descriptions/hpsj5s.desc descriptions/hs2p.desc descriptions/ibm.desc \
descriptions/kodak.desc descriptions/kvs1025.desc descriptions/kvs20xx.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 \

Wyświetl plik

@ -0,0 +1,37 @@
;
; SANE Backend specification file for the magicolor backend
;
; Copyright (C) 2010-11 Reinhold Kainhofer
; Released under GPLv2
;
:backend "magicolor"
:version "1.0.0"
:new :yes
: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."

Wyświetl plik

@ -1434,6 +1434,11 @@
: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

Wyświetl plik

@ -0,0 +1,72 @@
.\" .IX sane-magicolor
.TH "sane-magicolor" "5" "08 Feb 2005" "@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 decribes 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 <reinhold@kainhofer.com>

Wyświetl plik

@ -346,6 +346,11 @@ 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)