Removed direct dependence of sm3600 on libusb. Used sanei_usb instead. Based on

patch from Francois Revol <revol@free.fr>.  Updated documentation
accordingly. Fixed compilation warnings.
merge-requests/1/head
Henning Geinitz 2005-08-16 19:50:34 +00:00
rodzic ee11f5abcf
commit a2f1183de1
10 zmienionych plików z 101 dodań i 106 usunięć

Wyświetl plik

@ -11,7 +11,13 @@
* tools/check-usb-chip.c: Added check for combination of a
PowerVision PV8630 (USB->parport bridge) and National
Semiconductor LM9830 as used in the HP 4200. Fixed compilation
warning.
warning.
* configure configure.in backend/Makefile.in backend/sm3600-scanusb.c
backend/sm3600-scanutil.c backend/sm3600.c backend/sm3600.h
doc/sane-sm3600.man doc/sane-usb.man:
Removed direct dependence of sm3600 on libusb. Used sanei_usb
instead. Based on patch from François Revol <revol@free.fr>.
Updated documentation accordingly. Fixed compilation warnings.
2005-08-15 Oliver Schwartz <Oliver.Schwartz@gmx.de>

Wyświetl plik

@ -430,6 +430,7 @@ libsane-sharp.la: ../sanei/sanei_config2.lo
libsane-sharp.la: ../sanei/sanei_constrain_value.lo
libsane-sharp.la: ../sanei/sanei_scsi.lo
libsane-sm3600.la: ../sanei/sanei_constrain_value.lo
libsane-sm3600.la: ../sanei/sanei_usb.lo
libsane-sm3840.la: ../sanei/sanei_config2.lo
libsane-sm3840.la: ../sanei/sanei_constrain_value.lo
libsane-sm3840.la: ../sanei/sanei_usb.lo

Wyświetl plik

@ -68,14 +68,20 @@ static int TransferControlMsg(TInstance *this,
int cchBuffer,
int cJiffiesTimeout)
{
return usb_control_msg(this->hScanner,
SANE_Status err;
cJiffiesTimeout = cJiffiesTimeout;
err = sanei_usb_control_msg (this->hScanner,
nReqType,
nRequest,
nValue,
nIndex,
pBuffer,
cchBuffer,
cJiffiesTimeout);
pBuffer);
if (err)
return err;
return cchBuffer;
}
/* **********************************************************************
@ -90,11 +96,18 @@ static int TransferBulkRead(TInstance *this,
int cchMax,
int cJiffiesTimeout)
{
return usb_bulk_read(this->hScanner,
nEndPoint,
pBuffer,
cchMax,
cJiffiesTimeout);
int err;
size_t sz = cchMax;
nEndPoint = nEndPoint;
cJiffiesTimeout = cJiffiesTimeout;
err = sanei_usb_read_bulk(this->hScanner,
pBuffer,
&sz);
if (err)
return err;
return sz;
}
/* **********************************************************************
@ -310,7 +323,9 @@ int BulkRead(TInstance *this, FILE *fhOut, unsigned int cchBulk)
{
rc=SetError(this,SANE_STATUS_IO_ERROR,
"bulk read of %d bytes failed: %s",
cchChunk,usb_strerror());
cchChunk,
"I/O error"
);
continue;
}
}
@ -371,7 +386,9 @@ int BulkReadBuffer(TInstance *this,
else
rc=SetError(this,SANE_STATUS_IO_ERROR,
"bulk read of %d bytes failed: %s",
cchChunk,usb_strerror());
cchChunk,
"I/O error"
);
}
dprintf(DEBUG_COMM,"writing %d bytes\n",cchRead);

Wyświetl plik

@ -47,6 +47,7 @@ $Id$
====================================================================== */
#include <unistd.h>
#include "sm3600-scantool.h"
/* **********************************************************************

Wyświetl plik

@ -55,24 +55,25 @@ Start: 2.4.2001
====================================================================== */
#include "sane/config.h"
#include "../include/sane/config.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <usb.h>
#define BUILD 5
#define BUILD 6
#ifndef BACKEND_NAME
#define BACKEND_NAME sm3600
#endif
#include "sane/sane.h"
#include "sane/sanei.h"
#include "sane/sanei_backend.h"
#include "sane/sanei_config.h"
#include "sane/saneopts.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"
#undef HAVE_LIBUSB
/* prevent inclusion of scantool.h */
#define SCANTOOL_H
@ -326,7 +327,8 @@ InitOptions(TInstance *this)
}
static SANE_Status
RegisterSaneDev (struct usb_device *pdevUSB, TModel model, char *szName){
RegisterSaneDev (TModel model, SANE_String_Const szName)
{
TDevice * q;
errno = 0;
@ -342,7 +344,6 @@ RegisterSaneDev (struct usb_device *pdevUSB, TModel model, char *szName){
q->sane.model = "ScanMaker 3600";
q->sane.type = "flatbed scanner";
q->pdev=pdevUSB;
q->model=model;
++num_devices;
@ -351,13 +352,37 @@ RegisterSaneDev (struct usb_device *pdevUSB, TModel model, char *szName){
return SANE_STATUS_GOOD;
}
static SANE_Status
sm_usb_attach (SANE_String_Const dev_name)
{
int fd;
SANE_Status err;
SANE_Word v, p;
TModel model;
err = sanei_usb_open(dev_name, &fd);
if (err)
return err;
err = sanei_usb_get_vendor_product (fd, &v, &p);
if (err)
{
sanei_usb_close (fd);
return err;
}
DBG (DEBUG_JUNK, "found dev %04X/%04X, %s\n", v, p, dev_name);
model = GetScannerModel (v, p);
if (model != unknown)
RegisterSaneDev (model, dev_name);
sanei_usb_close(fd);
return SANE_STATUS_GOOD;
}
SANE_Status
sane_init (SANE_Int *version_code, SANE_Auth_Callback authCB)
{
struct usb_bus *pbus;
struct usb_device *pdev;
int iBus;
int i;
DBG_INIT();
@ -372,38 +397,11 @@ sane_init (SANE_Int *version_code, SANE_Auth_Callback authCB)
}
pdevFirst=NULL;
usb_init();
usb_find_busses();
if (!usb_busses)
return SANE_STATUS_IO_ERROR;
usb_find_devices();
iBus=0;
DBG(DEBUG_INFO,"starting bus scan\n");
for (pbus = usb_busses; pbus; pbus = pbus->next)
sanei_usb_init();
for (i = 0; aScanners[i].idProduct; i++)
{
int iDev=0;
iBus++;
/* 0.1.3b no longer has a "busnum" member */
DBG(DEBUG_JUNK,"scanning bus %s\n", pbus->dirname);
for (pdev=pbus->devices; pdev; pdev = pdev->next)
{
TModel model;
iDev++;
DBG(DEBUG_JUNK,"found dev %04X/%04X\n",
pdev->descriptor.idVendor,
pdev->descriptor.idProduct);
model=GetScannerModel(pdev->descriptor.idVendor,
pdev->descriptor.idProduct);
if (model!=unknown)
{
char ach[100];
sprintf(ach,"%d/%d",iBus,iDev);
RegisterSaneDev(pdev,model,ach);
}
}
sanei_usb_find_devices(SCANNER_VENDOR, aScanners[i].idProduct, sm_usb_attach);
}
return SANE_STATUS_GOOD;
}
@ -464,8 +462,11 @@ sane_open (SANE_String_Const devicename, SANE_Handle *handle)
if (devicename[0]) /* selected */
{
for (pdev=pdevFirst; pdev; pdev=pdev->pNext)
{
DBG(DEBUG_VERBOSE,"%s<>%s\n",devicename, pdev->sane.name);
if (!strcmp(devicename,pdev->sane.name))
break;
}
/* no dynamic post-registration */
}
else
@ -482,14 +483,11 @@ sane_open (SANE_String_Const devicename, SANE_Handle *handle)
pinstFirst=this;
this->model=pdev->model; /* memorize model */
/* open and prepare USB scanner handle */
this->hScanner=usb_open(pdev->pdev);
if (!this->hScanner)
return SetError(this,SANE_STATUS_IO_ERROR, "cannot open scanner device");
rc=SANE_STATUS_GOOD;
if (usb_claim_interface(this->hScanner, 0))
return SetError(this,SANE_STATUS_IO_ERROR, "cannot claim IF");
if (usb_set_configuration(this->hScanner, 1))
return SetError(this,SANE_STATUS_IO_ERROR, "cannot set USB config 1");
if (sanei_usb_open (devicename, &this->hScanner) != SANE_STATUS_GOOD)
return SetError (this, SANE_STATUS_IO_ERROR, "cannot open scanner device");
rc = SANE_STATUS_GOOD;
this->quality=fast;
return InitOptions(this);
@ -505,8 +503,9 @@ sane_close (SANE_Handle handle)
{
if (this->state.bScanning)
EndScan(this);
usb_close(this->hScanner);
this->hScanner=NULL;
sanei_usb_close(this->hScanner);
this->hScanner=-1;
}
ResetCalibration(this); /* release calibration data */
/* unlink active device entry */

Wyświetl plik

@ -190,7 +190,7 @@ typedef struct TInstance {
TQuality quality;
TMode mode;
TModel model;
usb_dev_handle *hScanner;
int hScanner;
FILE *fhLog;
FILE *fhScan;
int ichPageBuffer; /* write position in full page buffer */

9
configure vendored
Wyświetl plik

@ -26142,7 +26142,8 @@ echo "$as_me: Manually selected backends: ${BACKENDS}" >&6;}
microtek2 mustek mustek_usb nec pie plustek \
plustek_pp ricoh s9036 sceptre sharp \
sp15c st400 tamarack test teco1 teco2 teco3 umax umax_pp umax1220u \
artec_eplus48u ma1509 ibm hp5400 u12 snapscan niash sm3840 hp4200"
artec_eplus48u ma1509 ibm hp5400 u12 snapscan niash sm3840 hp4200 \
sm3600"
if test "${sane_cv_use_libjpeg}" != "yes"; then
echo "*** disabling DC210 backend (failed to find JPEG library)"
@ -26216,12 +26217,6 @@ else
echo "*** disabling pnm backend (not selected manually)"
fi;
if test "${HAVE_LIBUSB}" != "yes" ; then
echo "*** disabling SM3600 backend (libusb or usb.h not found)"
else
BACKENDS="${BACKENDS} sm3600"
fi
fi
fi

Wyświetl plik

@ -337,7 +337,8 @@ else
microtek2 mustek mustek_usb nec pie plustek \
plustek_pp ricoh s9036 sceptre sharp \
sp15c st400 tamarack test teco1 teco2 teco3 umax umax_pp umax1220u \
artec_eplus48u ma1509 ibm hp5400 u12 snapscan niash sm3840 hp4200"
artec_eplus48u ma1509 ibm hp5400 u12 snapscan niash sm3840 hp4200 \
sm3600"
if test "${sane_cv_use_libjpeg}" != "yes"; then
echo "*** disabling DC210 backend (failed to find JPEG library)"
@ -409,12 +410,6 @@ else
], [
echo "*** disabling pnm backend (not selected manually)"
])
if test "${HAVE_LIBUSB}" != "yes" ; then
echo "*** disabling SM3600 backend (libusb or usb.h not found)"
else
BACKENDS="${BACKENDS} sm3600"
fi
fi
fi

Wyświetl plik

@ -1,4 +1,4 @@
.TH sane-sm3600 5 "10.02.2002" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy"
.TH sane-sm3600 5 "16 August 2005" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy"
.IX sane-sm3600
.SH NAME
sane-sm3600 \- SANE backend for Microtek scanners with M011 USB chip
@ -9,7 +9,7 @@ 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 exist a backends for Microtek scanners with SCSI command set.
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
@ -56,23 +56,6 @@ The static library implementing this backend.
The shared library implementing this backend (present on systems that
support dynamic loading).
.SH PERMISSIONS AND INTERFACES
The backend uses \fBlibusb\fR and it's pseudo files in
\fI/proc/bus/usb/*\fR. Since \fBlibusb\fR versions 0.1.3b and 0.1.4 have
incompatible binary data structures, You must be shure not to have obsolete
header files. When You mix wrong versions, the scanner detection code will
raise a "segment violation".
These files are normally owned by \fBroot\fR and You are responsible
to get access to these files, for example \fBchown\fR-ing them to
Yourself. If You have no right permissions, the backend will find the
device, but You'll get an I/O error.
The better way is to use automatical \fBhotplugging\fR. See
\fIhttp://sm3600.sf.net/hotplug.html\fR for instructions and useful
links.
.SH ENVIRONMENT
.TP
.B SANE_DEBUG_SM3600

Wyświetl plik

@ -1,4 +1,4 @@
.TH sane-usb 5 "29 May 2005" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy"
.TH sane-usb 5 "16 August 2005" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy"
.IX sane-usb
.SH NAME
sane-usb \- USB configuration tips for SANE
@ -7,14 +7,12 @@ 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 most backends and scanners, as they use the generic
sanei_usb interface. However, there are some exceptions: USB Scanners
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. The sm3600 backend accesses scanners over libusb dierctly. See the
appropriate section in this manpage and
.BR sane-sm3600 (5).
for details.
.SH "QUICK START"
This is a short HOWTO-like section. For the full details, read the following