kopia lustrzana https://gitlab.com/sane-project/backends
plustek-pp: removed conditionally compiled code for Linux driver.
Mainly consists of removing code for #ifdef __KERNEL__ In order to keep it really clear what code has been removed, I have not corrected any formatting issues.merge-requests/708/head
rodzic
3635176eb9
commit
27a7c4518e
|
@ -235,11 +235,7 @@ typedef const struct mode_param
|
||||||
#define _E_SEQUENCE (_FIRST_ERR-30) /* caller sequence does not match */
|
#define _E_SEQUENCE (_FIRST_ERR-30) /* caller sequence does not match */
|
||||||
#define _E_NO_ASIC (_FIRST_ERR-31) /* can't detect ASIC */
|
#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 */
|
# define _E_FAULT (_E_INTERNAL) /* should never happen in userspace */
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _E_LAMP_NOT_IN_POS (_FIRST_ERR-40)
|
#define _E_LAMP_NOT_IN_POS (_FIRST_ERR-40)
|
||||||
#define _E_LAMP_NOT_STABLE (_FIRST_ERR-41)
|
#define _E_LAMP_NOT_STABLE (_FIRST_ERR-41)
|
||||||
|
@ -471,10 +467,6 @@ typedef struct {
|
||||||
#define _ScanMode_AverageOut 1 /* CCD averaged 2 pixels value for output*/
|
#define _ScanMode_AverageOut 1 /* CCD averaged 2 pixels value for output*/
|
||||||
#define _ScanMode_Mono 2 /* not color mode */
|
#define _ScanMode_Mono 2 /* not color mode */
|
||||||
|
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
|
|
||||||
|
|
||||||
#define PLUSTEK_CONFIG_FILE "plustek_pp.conf"
|
#define PLUSTEK_CONFIG_FILE "plustek_pp.conf"
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
|
@ -631,7 +623,6 @@ typedef struct {
|
||||||
AdjDef adj;
|
AdjDef adj;
|
||||||
|
|
||||||
} CnfDef, *pCnfDef;
|
} CnfDef, *pCnfDef;
|
||||||
#endif /* guard __KERNEL__ */
|
|
||||||
|
|
||||||
#endif /* guard __PLUSTEKPP_H__ */
|
#endif /* guard __PLUSTEKPP_H__ */
|
||||||
|
|
||||||
|
|
|
@ -46,23 +46,12 @@
|
||||||
/* uncomment this to have an SW-simulatet 98001 device - don't expect to scan*/
|
/* uncomment this to have an SW-simulatet 98001 device - don't expect to scan*/
|
||||||
/* #define _ASIC_98001_SIM */
|
/* #define _ASIC_98001_SIM */
|
||||||
|
|
||||||
/*
|
|
||||||
* the print macros
|
|
||||||
*/
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
# define _PRINT printk
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* some debug definitions
|
* some debug definitions
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# ifndef __KERNEL__
|
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
# define _ASSERT(x) assert(x)
|
# define _ASSERT(x) assert(x)
|
||||||
# else
|
|
||||||
# define _ASSERT(x)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef DBG
|
# ifndef DBG
|
||||||
# define DBG(level, msg, args...) if ((dbg_level) & (level)) { \
|
# define DBG(level, msg, args...) if ((dbg_level) & (level)) { \
|
||||||
|
|
|
@ -97,11 +97,6 @@ static int detectScannerConnection( pScanData ps )
|
||||||
UChar data, control, status;
|
UChar data, control, status;
|
||||||
int retval = _E_NO_CONN;
|
int retval = _E_NO_CONN;
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
DBG( DBG_LOW, "Dataport = 0x%04x\n", ps->IO.pbSppDataPort );
|
|
||||||
DBG( DBG_LOW, "Ctrlport = 0x%04x\n", ps->IO.pbControlPort );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
detectResetPort( ps );
|
detectResetPort( ps );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -177,11 +172,7 @@ static int detectScannerConnection( pScanData ps )
|
||||||
|
|
||||||
/* work on the result */
|
/* work on the result */
|
||||||
if ( _OK == retval ) {
|
if ( _OK == retval ) {
|
||||||
#ifdef __KERNEL__
|
|
||||||
ps->sCaps.wIOBase = ps->IO.pbSppDataPort;
|
|
||||||
#else
|
|
||||||
ps->sCaps.wIOBase = ps->pardev;
|
ps->sCaps.wIOBase = ps->pardev;
|
||||||
#endif
|
|
||||||
ps->PutToIdleMode( ps );
|
ps->PutToIdleMode( ps );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -209,11 +200,7 @@ static int detectSetupBuffers( pScanData ps )
|
||||||
*/
|
*/
|
||||||
if ( 0 == ps->TotalBufferRequire ) {
|
if ( 0 == ps->TotalBufferRequire ) {
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"pt_drv: asic 0x%x probably not supported\n", ps->sCaps.AsicID);
|
"pt_drv: asic 0x%x probably not supported\n", ps->sCaps.AsicID);
|
||||||
|
|
||||||
return _E_ALLOC; /* Out of memory */
|
return _E_ALLOC; /* Out of memory */
|
||||||
|
@ -228,11 +215,7 @@ static int detectSetupBuffers( pScanData ps )
|
||||||
|
|
||||||
if ( NULL == ps->driverbuf ) {
|
if ( NULL == ps->driverbuf ) {
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"pt_drv: Not enough kernel memory %d\n",
|
"pt_drv: Not enough kernel memory %d\n",
|
||||||
ps->TotalBufferRequire);
|
ps->TotalBufferRequire);
|
||||||
return _E_ALLOC; /* Out of memory */
|
return _E_ALLOC; /* Out of memory */
|
||||||
|
@ -379,12 +362,8 @@ static int detectAsic98001( pScanData ps )
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
return detectScannerConnection( ps );
|
return detectScannerConnection( ps );
|
||||||
#else
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
#else
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"!!!! WARNING, have a look at function detectAsic98001() !!!!\n" );
|
"!!!! WARNING, have a look at function detectAsic98001() !!!!\n" );
|
||||||
ps->sCaps.AsicID = _ASIC_IS_98001;
|
ps->sCaps.AsicID = _ASIC_IS_98001;
|
||||||
ps->sCaps.wIOBase = ps->IO.pbSppDataPort;
|
ps->sCaps.wIOBase = ps->IO.pbSppDataPort;
|
||||||
|
@ -434,11 +413,7 @@ _LOC int DetectScanner( pScanData ps, int mode )
|
||||||
|
|
||||||
/* read Register 0x18 (AsicID Register) of Asic9800x based devices */
|
/* read Register 0x18 (AsicID Register) of Asic9800x based devices */
|
||||||
#ifdef _ASIC_98001_SIM
|
#ifdef _ASIC_98001_SIM
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"!!!! WARNING, SW-Emulation active !!!!\n" );
|
"!!!! WARNING, SW-Emulation active !!!!\n" );
|
||||||
asic = _ASIC_IS_98001;
|
asic = _ASIC_IS_98001;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -586,19 +586,6 @@ typedef struct
|
||||||
* structure to hold IO port specific stuff
|
* structure to hold IO port specific stuff
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
pFnOut fnOut;
|
|
||||||
pFnIn fnIn;
|
|
||||||
|
|
||||||
UShort pbSppDataPort;
|
|
||||||
UShort pbEppDataPort;
|
|
||||||
|
|
||||||
UShort pbStatusPort;
|
|
||||||
UShort pbControlPort;
|
|
||||||
UShort pbAddrOffsetPort;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UShort portBase;
|
UShort portBase;
|
||||||
UShort portMode;
|
UShort portMode;
|
||||||
UShort lastPortMode;
|
UShort lastPortMode;
|
||||||
|
|
|
@ -1288,11 +1288,7 @@ static Bool imageP98003ReadOneImageLine( pScanData ps )
|
||||||
|
|
||||||
} while( !MiscCheckTimer( &timer ));
|
} while( !MiscCheckTimer( &timer ));
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"Timeout - Scanner malfunction !!\n" );
|
"Timeout - Scanner malfunction !!\n" );
|
||||||
MotorToHomePosition(ps);
|
MotorToHomePosition(ps);
|
||||||
|
|
||||||
|
|
|
@ -257,21 +257,11 @@ static Bool fnEPPRead( pScanData ps, pUChar pBuffer, ULong ulSize )
|
||||||
|
|
||||||
if( _IS_ASIC98(ps->sCaps.AsicID)) {
|
if( _IS_ASIC98(ps->sCaps.AsicID)) {
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
sanei_pp_set_datadir( ps->pardev, SANEI_PP_DATAIN );
|
sanei_pp_set_datadir( ps->pardev, SANEI_PP_DATAIN );
|
||||||
#else
|
|
||||||
_OUTB_CTRL( ps, (_CTRL_GENSIGNAL + _CTRL_DIRECTION));
|
|
||||||
_DO_UDELAY( 1 );
|
|
||||||
#endif
|
|
||||||
for( i = 0; i < ulSize; i++ )
|
for( i = 0; i < ulSize; i++ )
|
||||||
pBuffer[i] = _INB_EPPDATA( ps );
|
pBuffer[i] = _INB_EPPDATA( ps );
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
sanei_pp_set_datadir( ps->pardev, SANEI_PP_DATAOUT );
|
sanei_pp_set_datadir( ps->pardev, SANEI_PP_DATAOUT );
|
||||||
#else
|
|
||||||
_OUTB_CTRL( ps, _CTRL_GENSIGNAL );
|
|
||||||
_DO_UDELAY( 1 );
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for( i = 0; i < ulSize; i++ )
|
for( i = 0; i < ulSize; i++ )
|
||||||
|
@ -290,18 +280,12 @@ static Bool fnBiDirRead( pScanData ps, pUChar pBuffer, ULong ulSize )
|
||||||
start = _CTRL_START_BIDIREAD;
|
start = _CTRL_START_BIDIREAD;
|
||||||
end = _CTRL_END_BIDIREAD;
|
end = _CTRL_END_BIDIREAD;
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
sanei_pp_set_datadir( ps->pardev, SANEI_PP_DATAIN );
|
sanei_pp_set_datadir( ps->pardev, SANEI_PP_DATAIN );
|
||||||
|
|
||||||
if( !sanei_pp_uses_directio()) {
|
if( !sanei_pp_uses_directio()) {
|
||||||
start &= ~_CTRL_DIRECTION;
|
start &= ~_CTRL_DIRECTION;
|
||||||
end &= ~_CTRL_DIRECTION;
|
end &= ~_CTRL_DIRECTION;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if( _IS_ASIC98(ps->sCaps.AsicID)) {
|
|
||||||
_OUTB_CTRL( ps, (_CTRL_GENSIGNAL + _CTRL_DIRECTION));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch( ps->IO.delay ) {
|
switch( ps->IO.delay ) {
|
||||||
|
|
||||||
|
@ -341,13 +325,7 @@ static Bool fnBiDirRead( pScanData ps, pUChar pBuffer, ULong ulSize )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
sanei_pp_set_datadir( ps->pardev, SANEI_PP_DATAOUT );
|
sanei_pp_set_datadir( ps->pardev, SANEI_PP_DATAOUT );
|
||||||
#else
|
|
||||||
if( _IS_ASIC98(ps->sCaps.AsicID)) {
|
|
||||||
_OUTB_CTRL( ps, _CTRL_GENSIGNAL );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return _TRUE;
|
return _TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,45 +931,4 @@ _LOC void IOReadScannerImageData( pScanData ps, pUChar pBuf, ULong size )
|
||||||
ps->OpenScanPath( ps );
|
ps->OpenScanPath( ps );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
|
|
||||||
/** the wrapper functions to support delayed and non-delayed I/O
|
|
||||||
*/
|
|
||||||
_LOC void IOOut( Byte data, UShort port )
|
|
||||||
{
|
|
||||||
DBG( DBG_IOF, "sanei_outb(0x%04x, 0x%02x)\n", port, data );
|
|
||||||
sanei_outb( port, data );
|
|
||||||
}
|
|
||||||
|
|
||||||
_LOC void IOOutDelayed( Byte data, UShort port )
|
|
||||||
{
|
|
||||||
DBG( DBG_IOF, "sanei_outb_p(0x%04x, 0x%02x)\n", port, data );
|
|
||||||
sanei_outb_p( port, data );
|
|
||||||
}
|
|
||||||
|
|
||||||
_LOC Byte IOIn( UShort port )
|
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
|
||||||
Byte data = sani_inb( port );
|
|
||||||
|
|
||||||
DBG( DBG_IOF, "sanei_inb(0x%04x) = 0x%02x\n", port, data );
|
|
||||||
return data;
|
|
||||||
#else
|
|
||||||
return sanei_inb( port );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
_LOC Byte IOInDelayed( UShort port )
|
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
|
||||||
Byte data = sanei_inb_p( port );
|
|
||||||
|
|
||||||
DBG( DBG_IOF, "sanei_inb_p(0x%04x) = 0x%02x\n", port, data );
|
|
||||||
return data;
|
|
||||||
#else
|
|
||||||
return sanei_inb_p( port );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif /* guard __KERNEL__ */
|
|
||||||
|
|
||||||
/* END PLUSTEK-PP_IO.C ......................................................*/
|
/* END PLUSTEK-PP_IO.C ......................................................*/
|
||||||
|
|
|
@ -77,27 +77,11 @@
|
||||||
|
|
||||||
/*************************** some definitions ********************************/
|
/*************************** some definitions ********************************/
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
# define PPA_PROBE_SPP 0x0001
|
# define PPA_PROBE_SPP 0x0001
|
||||||
# define PPA_PROBE_PS2 0x0002
|
# define PPA_PROBE_PS2 0x0002
|
||||||
# define PPA_PROBE_ECR 0x0010
|
# define PPA_PROBE_ECR 0x0010
|
||||||
# define PPA_PROBE_EPP17 0x0100
|
# define PPA_PROBE_EPP17 0x0100
|
||||||
# define PPA_PROBE_EPP19 0x0200
|
# 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_A 16807 /**< multiplier */
|
||||||
#define _PP_M 2147483647L /**< 2**31 - 1 */
|
#define _PP_M 2147483647L /**< 2**31 - 1 */
|
||||||
|
@ -107,299 +91,10 @@
|
||||||
static int port_feature = 0;
|
static int port_feature = 0;
|
||||||
static long randomnum = 1;
|
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 };
|
static int portIsClaimed[_MAX_PTDEVS] = { 0, 0, 0, 0 };
|
||||||
#endif
|
|
||||||
|
|
||||||
/*************************** local functions *********************************/
|
/*************************** 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 available 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 attempt 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 ((sanei_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
|
/** miscNextLongRand() -- generate 2**31-2 random numbers
|
||||||
**
|
**
|
||||||
** public domain by Ray Gardner
|
** public domain by Ray Gardner
|
||||||
|
@ -488,34 +183,6 @@ _LOC int MiscReinitStruct( pScanData ps )
|
||||||
*/
|
*/
|
||||||
_LOC int MiscInitPorts( pScanData ps, int port )
|
_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;
|
int mode, mts;
|
||||||
|
|
||||||
if( NULL == ps )
|
if( NULL == ps )
|
||||||
|
@ -560,7 +227,6 @@ _LOC int MiscInitPorts( pScanData ps, int port )
|
||||||
|
|
||||||
sanei_pp_setmode( ps->pardev, mts );
|
sanei_pp_setmode( ps->pardev, mts );
|
||||||
_VAR_NOT_USED( port );
|
_VAR_NOT_USED( port );
|
||||||
#endif
|
|
||||||
return _OK;
|
return _OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,11 +234,6 @@ _LOC int MiscInitPorts( pScanData ps, int port )
|
||||||
*/
|
*/
|
||||||
_LOC void MiscRestorePort( pScanData ps )
|
_LOC void MiscRestorePort( pScanData ps )
|
||||||
{
|
{
|
||||||
#ifdef __KERNEL__
|
|
||||||
if( 0 == ps->IO.pbSppDataPort )
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DBG(DBG_LOW,"MiscRestorePort()\n");
|
DBG(DBG_LOW,"MiscRestorePort()\n");
|
||||||
|
|
||||||
/* don't restore if not necessary */
|
/* don't restore if not necessary */
|
||||||
|
@ -582,19 +243,9 @@ _LOC void MiscRestorePort( pScanData ps )
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Restore Port-Mode*/
|
/*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 ){
|
if( port_feature & PPA_PROBE_ECR ){
|
||||||
_OUTB_ECTL(ps,ps->IO.lastPortMode);
|
_OUTB_ECTL(ps,ps->IO.lastPortMode);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes a timer.
|
/** Initializes a timer.
|
||||||
|
@ -605,11 +256,7 @@ _LOC void MiscStartTimer( TimerDef *timer , unsigned long us)
|
||||||
{
|
{
|
||||||
struct timeval start_time;
|
struct timeval start_time;
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
_GET_TIME( &start_time );
|
|
||||||
#else
|
|
||||||
gettimeofday(&start_time, NULL);
|
gettimeofday(&start_time, NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
*timer = (TimerDef)start_time.tv_sec * 1000000 + (TimerDef)start_time.tv_usec + us;
|
*timer = (TimerDef)start_time.tv_sec * 1000000 + (TimerDef)start_time.tv_usec + us;
|
||||||
}
|
}
|
||||||
|
@ -624,21 +271,14 @@ _LOC int MiscCheckTimer( TimerDef *timer )
|
||||||
{
|
{
|
||||||
struct timeval current_time;
|
struct timeval current_time;
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
_GET_TIME( ¤t_time );
|
|
||||||
#else
|
|
||||||
gettimeofday(¤t_time, NULL);
|
gettimeofday(¤t_time, NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((TimerDef)current_time.tv_sec * 1000000 + (TimerDef)current_time.tv_usec > *timer) {
|
if ((TimerDef)current_time.tv_sec * 1000000 + (TimerDef)current_time.tv_usec > *timer) {
|
||||||
return _E_TIMEOUT;
|
return _E_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
#ifdef __KERNEL__
|
|
||||||
schedule();
|
|
||||||
/*#else
|
/*#else
|
||||||
sched_yield();
|
sched_yield();
|
||||||
*/
|
*/
|
||||||
#endif
|
|
||||||
return _OK;
|
return _OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,65 +313,8 @@ _LOC Bool MiscAllPointersSet( pScanData ps )
|
||||||
*/
|
*/
|
||||||
_LOC int MiscRegisterPort( pScanData ps, int portAddr )
|
_LOC int MiscRegisterPort( pScanData ps, int portAddr )
|
||||||
{
|
{
|
||||||
#ifndef __KERNEL__
|
|
||||||
DBG( DBG_LOW, "Assigning port handle %i\n", portAddr );
|
DBG( DBG_LOW, "Assigning port handle %i\n", portAddr );
|
||||||
ps->pardev = 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;
|
portIsClaimed[ps->devno] = 0;
|
||||||
return _OK;
|
return _OK;
|
||||||
|
@ -741,17 +324,7 @@ _LOC int MiscRegisterPort( pScanData ps, int portAddr )
|
||||||
*/
|
*/
|
||||||
_LOC void MiscUnregisterPort( pScanData ps )
|
_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 );
|
sanei_pp_close( ps->pardev );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Try to claim the port
|
/** Try to claim the port
|
||||||
|
@ -763,11 +336,7 @@ _LOC int MiscClaimPort( pScanData ps )
|
||||||
if( 0 == portIsClaimed[ps->devno] ) {
|
if( 0 == portIsClaimed[ps->devno] ) {
|
||||||
|
|
||||||
DBG( DBG_HIGH, "Try to claim the parport\n" );
|
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 )) {
|
if( SANE_STATUS_GOOD != sanei_pp_claim( ps->pardev )) {
|
||||||
#endif
|
|
||||||
return _E_BUSY;
|
return _E_BUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -785,11 +354,7 @@ _LOC void MiscReleasePort( pScanData ps )
|
||||||
|
|
||||||
if( 0 == portIsClaimed[ps->devno] ) {
|
if( 0 == portIsClaimed[ps->devno] ) {
|
||||||
DBG( DBG_HIGH, "Releasing parport\n" );
|
DBG( DBG_HIGH, "Releasing parport\n" );
|
||||||
#ifdef __KERNEL__
|
|
||||||
parport_release( ps->pardev );
|
|
||||||
#else
|
|
||||||
sanei_pp_release( ps->pardev );
|
sanei_pp_release( ps->pardev );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,13 +219,6 @@ _LOC void IORegisterDirectToScanner( pScanData, Byte bReg );
|
||||||
_LOC void IOSoftwareReset ( pScanData ps );
|
_LOC void IOSoftwareReset ( pScanData ps );
|
||||||
_LOC void IOReadScannerImageData ( pScanData ps, pUChar pBuf, ULong size );
|
_LOC void IOReadScannerImageData ( pScanData ps, pUChar pBuf, ULong size );
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
_LOC void IOOut ( Byte data, UShort port );
|
|
||||||
_LOC void IOOutDelayed( Byte data, UShort port );
|
|
||||||
_LOC Byte IOIn ( UShort port );
|
|
||||||
_LOC Byte IOInDelayed ( UShort port );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* implementation in plustek-pp_tpa.c
|
* implementation in plustek-pp_tpa.c
|
||||||
*/
|
*/
|
||||||
|
@ -238,16 +231,6 @@ _LOC void TPAP98003Reshading ( pScanData ps );
|
||||||
*/
|
*/
|
||||||
_LOC void ScaleX( pScanData ps, pUChar inBuf, pUChar outBuf );
|
_LOC void ScaleX( pScanData ps, pUChar inBuf, pUChar outBuf );
|
||||||
|
|
||||||
/*
|
|
||||||
* implementation in plustek-pp_procfs.c (Kernel-mode only)
|
|
||||||
*/
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
int ProcFsInitialize ( void );
|
|
||||||
void ProcFsShutdown ( void );
|
|
||||||
void ProcFsRegisterDevice ( pScanData ps );
|
|
||||||
void ProcFsUnregisterDevice( pScanData ps );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* guard __PROCS_H__ */
|
#endif /* guard __PROCS_H__ */
|
||||||
|
|
||||||
/* END PLUSTEK-PP_PROCS.H ...................................................*/
|
/* END PLUSTEK-PP_PROCS.H ...................................................*/
|
||||||
|
|
|
@ -94,52 +94,13 @@
|
||||||
* If you do not wish that, delete this exception notice.
|
* If you do not wish that, delete this exception notice.
|
||||||
* <hr>
|
* <hr>
|
||||||
*/
|
*/
|
||||||
#ifdef __KERNEL__
|
|
||||||
# include <linux/module.h>
|
|
||||||
# include <linux/version.h>
|
|
||||||
|
|
||||||
# ifdef CONFIG_DEVFS_FS
|
|
||||||
# include <linux/devfs_fs_kernel.h>
|
|
||||||
# if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,69))
|
|
||||||
# define DEVFS_26_STYLE
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "plustek-pp_scan.h"
|
#include "plustek-pp_scan.h"
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
# include <linux/param.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************** static vars **********************************/
|
/****************************** static vars **********************************/
|
||||||
|
|
||||||
/* default port is at 0x378 */
|
/* default port is at 0x378 */
|
||||||
static int port[_MAX_PTDEVS] = { 0x378, 0, 0, 0 };
|
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 pScanData PtDrvDevices[_MAX_PTDEVS]= { NULL, NULL, NULL, NULL };
|
||||||
static int lampoff[_MAX_PTDEVS] = { 180, 180, 180, 180 };
|
static int lampoff[_MAX_PTDEVS] = { 180, 180, 180, 180 };
|
||||||
static int warmup[_MAX_PTDEVS] = { 30, 30, 30, 30 };
|
static int warmup[_MAX_PTDEVS] = { 30, 30, 30, 30 };
|
||||||
|
@ -147,140 +108,14 @@ static int lOffonEnd[_MAX_PTDEVS] = { 0, 0, 0, 0 };
|
||||||
static UShort mov[_MAX_PTDEVS] = { 0, 0, 0, 0 };
|
static UShort mov[_MAX_PTDEVS] = { 0, 0, 0, 0 };
|
||||||
static UShort forceMode[_MAX_PTDEVS] = { 0, 0, 0, 0 };
|
static UShort forceMode[_MAX_PTDEVS] = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* timers for warmup checks */
|
/* timers for warmup checks */
|
||||||
static TimerDef toTimer[_MAX_PTDEVS];
|
static TimerDef toTimer[_MAX_PTDEVS];
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
static Bool PtDrvInitialized = _FALSE;
|
static Bool PtDrvInitialized = _FALSE;
|
||||||
#ifdef HAVE_SETITIMER
|
#ifdef HAVE_SETITIMER
|
||||||
static struct itimerval saveSettings;
|
static struct itimerval saveSettings;
|
||||||
#endif
|
#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 <gerhard@gjaeger.de>");
|
|
||||||
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 ******************************/
|
/****************************** some prototypes ******************************/
|
||||||
|
|
||||||
|
@ -288,23 +123,6 @@ static void ptdrvStartLampTimer( pScanData ps );
|
||||||
|
|
||||||
/****************************** local functions ******************************/
|
/****************************** 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
|
/** copy user-space data into kernel memory
|
||||||
*/
|
*/
|
||||||
static int getUserPtr(const pVoid useraddr, pVoid where, UInt size )
|
static int getUserPtr(const pVoid useraddr, pVoid where, UInt size )
|
||||||
|
@ -315,32 +133,9 @@ static int getUserPtr(const pVoid useraddr, pVoid where, UInt size )
|
||||||
if((NULL == useraddr) || ( 0 == size))
|
if((NULL == useraddr) || ( 0 == size))
|
||||||
return _E_INVALID;
|
return _E_INVALID;
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
if ((err = verify_area_20(VERIFY_READ, useraddr, size)))
|
|
||||||
return err;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (size) {
|
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:
|
default:
|
||||||
memcpy( where, useraddr, size );
|
memcpy( where, useraddr, size );
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -354,20 +149,11 @@ static int putUserPtr( const pVoid ptr, pVoid useraddr, UInt size )
|
||||||
if (NULL == useraddr)
|
if (NULL == useraddr)
|
||||||
return _E_INVALID;
|
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 );
|
memcpy( useraddr, ptr, size );
|
||||||
#endif
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
static unsigned long copy_from_user( pVoid dest, pVoid src, unsigned long len )
|
static unsigned long copy_from_user( pVoid dest, pVoid src, unsigned long len )
|
||||||
{
|
{
|
||||||
memcpy( dest, src, len );
|
memcpy( dest, src, len );
|
||||||
|
@ -379,37 +165,16 @@ static unsigned long copy_to_user( pVoid dest, pVoid src, unsigned long len )
|
||||||
memcpy( dest, src, len );
|
memcpy( dest, src, len );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
static int putUserVal(const ULong value, pVoid useraddr, UInt size)
|
static int putUserVal(const ULong value, pVoid useraddr, UInt size)
|
||||||
{
|
{
|
||||||
#ifdef __KERNEL__
|
|
||||||
int err;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (NULL == useraddr)
|
if (NULL == useraddr)
|
||||||
return _E_INVALID;
|
return _E_INVALID;
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
if ((err = verify_area_20(VERIFY_WRITE, useraddr, size)))
|
|
||||||
return err;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (size) {
|
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):
|
case sizeof(UChar):
|
||||||
*(pUChar)useraddr = (UChar)value;
|
*(pUChar)useraddr = (UChar)value;
|
||||||
break;
|
break;
|
||||||
|
@ -420,7 +185,6 @@ static int putUserVal(const ULong value, pVoid useraddr, UInt size)
|
||||||
*(pULong)useraddr = (ULong)value;
|
*(pULong)useraddr = (ULong)value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
return _E_INVALID;
|
return _E_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -506,22 +270,14 @@ static void ptdrvLampWarmup( pScanData ps )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
#ifdef __KERNEL__
|
|
||||||
static void ptdrvLampTimerIrq( unsigned long ptr )
|
|
||||||
#else
|
|
||||||
static void ptdrvLampTimerIrq( int sig_num )
|
static void ptdrvLampTimerIrq( int sig_num )
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
pScanData ps;
|
pScanData ps;
|
||||||
|
|
||||||
DBG( DBG_HIGH, "!! IRQ !! Lamp-Timer stopped.\n" );
|
DBG( DBG_HIGH, "!! IRQ !! Lamp-Timer stopped.\n" );
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
ps = (pScanData)ptr;
|
|
||||||
#else
|
|
||||||
_VAR_NOT_USED( sig_num );
|
_VAR_NOT_USED( sig_num );
|
||||||
ps = PtDrvDevices[0];
|
ps = PtDrvDevices[0];
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* paranoia check!
|
* paranoia check!
|
||||||
|
@ -559,7 +315,6 @@ static void ptdrvLampTimerIrq( int sig_num )
|
||||||
*/
|
*/
|
||||||
static void ptdrvStartLampTimer( pScanData ps )
|
static void ptdrvStartLampTimer( pScanData ps )
|
||||||
{
|
{
|
||||||
#ifndef __KERNEL__
|
|
||||||
sigset_t block, pause_mask;
|
sigset_t block, pause_mask;
|
||||||
struct sigaction s;
|
struct sigaction s;
|
||||||
#ifdef HAVE_SETITIMER
|
#ifdef HAVE_SETITIMER
|
||||||
|
@ -597,17 +352,6 @@ static void ptdrvStartLampTimer( pScanData ps )
|
||||||
#else
|
#else
|
||||||
alarm( ps->lampoff );
|
alarm( ps->lampoff );
|
||||||
#endif
|
#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" );
|
DBG( DBG_HIGH, "Lamp-Timer started!\n" );
|
||||||
}
|
}
|
||||||
|
@ -616,7 +360,6 @@ static void ptdrvStartLampTimer( pScanData ps )
|
||||||
*/
|
*/
|
||||||
static void ptdrvStopLampTimer( pScanData ps )
|
static void ptdrvStopLampTimer( pScanData ps )
|
||||||
{
|
{
|
||||||
#ifndef __KERNEL__
|
|
||||||
sigset_t block, pause_mask;
|
sigset_t block, pause_mask;
|
||||||
|
|
||||||
/* block SIGALRM */
|
/* block SIGALRM */
|
||||||
|
@ -630,10 +373,6 @@ static void ptdrvStopLampTimer( pScanData ps )
|
||||||
_VAR_NOT_USED( ps );
|
_VAR_NOT_USED( ps );
|
||||||
alarm(0);
|
alarm(0);
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
if( 0 != ps->lampoff )
|
|
||||||
del_timer( &tl[ps->devno] );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DBG( DBG_HIGH, "Lamp-Timer stopped!\n" );
|
DBG( DBG_HIGH, "Lamp-Timer stopped!\n" );
|
||||||
}
|
}
|
||||||
|
@ -701,23 +440,11 @@ static int ptdrvOpenDevice( pScanData ps )
|
||||||
UShort lastMode;
|
UShort lastMode;
|
||||||
ULong devno;
|
ULong devno;
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
UShort flags;
|
|
||||||
struct pardevice *pd;
|
|
||||||
struct parport *pp;
|
|
||||||
ProcDirDef procDir;
|
|
||||||
#else
|
|
||||||
int pd;
|
int pd;
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* push some values from the struct
|
* push some values from the struct
|
||||||
*/
|
*/
|
||||||
#ifdef __KERNEL__
|
|
||||||
flags = ps->flags;
|
|
||||||
pp = ps->pp;
|
|
||||||
procDir = ps->procDir;
|
|
||||||
#endif
|
|
||||||
pd = ps->pardev;
|
pd = ps->pardev;
|
||||||
iobase = ps->sCaps.wIOBase;
|
iobase = ps->sCaps.wIOBase;
|
||||||
asic = ps->sCaps.AsicID;
|
asic = ps->sCaps.AsicID;
|
||||||
|
@ -734,29 +461,10 @@ static int ptdrvOpenDevice( pScanData ps )
|
||||||
/*
|
/*
|
||||||
* pop the val(s)
|
* pop the val(s)
|
||||||
*/
|
*/
|
||||||
#ifdef __KERNEL__
|
|
||||||
ps->flags = flags;
|
|
||||||
ps->pp = pp;
|
|
||||||
ps->procDir = procDir;
|
|
||||||
#endif
|
|
||||||
ps->pardev = pd;
|
ps->pardev = pd;
|
||||||
ps->bLastLampStatus = lastStat;
|
ps->bLastLampStatus = lastStat;
|
||||||
ps->IO.lastPortMode = lastMode;
|
ps->IO.lastPortMode = lastMode;
|
||||||
ps->devno = devno;
|
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->ModelOverride = mov[devno];
|
||||||
ps->warmup = warmup[devno];
|
ps->warmup = warmup[devno];
|
||||||
ps->lampoff = lampoff[devno];
|
ps->lampoff = lampoff[devno];
|
||||||
|
@ -798,19 +506,6 @@ static int ptdrvInit( int devno )
|
||||||
return _E_ALLOC;
|
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->ModelOverride = mov[devno];
|
||||||
ps->warmup = warmup[devno];
|
ps->warmup = warmup[devno];
|
||||||
ps->lampoff = lampoff[devno];
|
ps->lampoff = lampoff[devno];
|
||||||
|
@ -845,13 +540,8 @@ static int ptdrvInit( int devno )
|
||||||
|
|
||||||
if( _OK == retval ) {
|
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",
|
DBG( DBG_LOW, "pt_drv%u: %s found\n",
|
||||||
devno, MiscGetModelName(ps->sCaps.Model));
|
devno, MiscGetModelName(ps->sCaps.Model));
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize the timespan timer
|
* initialize the timespan timer
|
||||||
|
@ -859,43 +549,23 @@ static int ptdrvInit( int devno )
|
||||||
MiscStartTimer( &toTimer[ps->devno], (_SECOND * ps->warmup));
|
MiscStartTimer( &toTimer[ps->devno], (_SECOND * ps->warmup));
|
||||||
|
|
||||||
if( 0 == ps->lampoff )
|
if( 0 == ps->lampoff )
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_LOW,
|
DBG( DBG_LOW,
|
||||||
#endif
|
|
||||||
"pt_drv%u: Lamp-Timer switched off.\n", devno );
|
"pt_drv%u: Lamp-Timer switched off.\n", devno );
|
||||||
else {
|
else {
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_LOW,
|
DBG( DBG_LOW,
|
||||||
#endif
|
|
||||||
"pt_drv%u: Lamp-Timer set to %u seconds.\n",
|
"pt_drv%u: Lamp-Timer set to %u seconds.\n",
|
||||||
devno, ps->lampoff );
|
devno, ps->lampoff );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_LOW,
|
DBG( DBG_LOW,
|
||||||
#endif
|
|
||||||
"pt_drv%u: WarmUp period set to %u seconds.\n",
|
"pt_drv%u: WarmUp period set to %u seconds.\n",
|
||||||
devno, ps->warmup );
|
devno, ps->warmup );
|
||||||
|
|
||||||
if( 0 == ps->lOffonEnd ) {
|
if( 0 == ps->lOffonEnd ) {
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_LOW,
|
DBG( DBG_LOW,
|
||||||
#endif
|
|
||||||
"pt_drv%u: Lamp untouched on driver unload.\n", devno );
|
"pt_drv%u: Lamp untouched on driver unload.\n", devno );
|
||||||
} else {
|
} else {
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_LOW,
|
DBG( DBG_LOW,
|
||||||
#endif
|
|
||||||
"pt_drv%u: Lamp switch-off on driver unload.\n", devno );
|
"pt_drv%u: Lamp switch-off on driver unload.\n", devno );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1287,31 +957,19 @@ static int ptdrvRead( pScanData ps, pUChar buffer, int count )
|
||||||
int retval = _OK;
|
int retval = _OK;
|
||||||
|
|
||||||
#ifdef _ASIC_98001_SIM
|
#ifdef _ASIC_98001_SIM
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_LOW,
|
DBG( DBG_LOW,
|
||||||
#endif
|
|
||||||
"pt_drv : Software-Emulation active, can't read!\n" );
|
"pt_drv : Software-Emulation active, can't read!\n" );
|
||||||
return _E_INVALID;
|
return _E_INVALID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if((NULL == buffer) || (NULL == ps)) {
|
if((NULL == buffer) || (NULL == ps)) {
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"pt_drv : Internal NULL-pointer!\n" );
|
"pt_drv : Internal NULL-pointer!\n" );
|
||||||
return _E_NULLPTR;
|
return _E_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( 0 == count ) {
|
if( 0 == count ) {
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"pt_drv%u: reading 0 bytes makes no sense!\n", ps->devno );
|
"pt_drv%u: reading 0 bytes makes no sense!\n", ps->devno );
|
||||||
return _E_INVALID;
|
return _E_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -1325,11 +983,7 @@ static int ptdrvRead( pScanData ps, pUChar buffer, int count )
|
||||||
* when using the cat /dev/pt_drv command!
|
* when using the cat /dev/pt_drv command!
|
||||||
*/
|
*/
|
||||||
if (!(ps->DataInf.dwVxdFlag & _VF_ENVIRONMENT_READY)) {
|
if (!(ps->DataInf.dwVxdFlag & _VF_ENVIRONMENT_READY)) {
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"pt_drv%u: Cannot read, driver not initialized!\n",ps->devno);
|
"pt_drv%u: Cannot read, driver not initialized!\n",ps->devno);
|
||||||
return _E_SEQUENCE;
|
return _E_SEQUENCE;
|
||||||
}
|
}
|
||||||
|
@ -1340,11 +994,7 @@ static int ptdrvRead( pScanData ps, pUChar buffer, int count )
|
||||||
ps->Scan.bp.pMonoBuf = _KALLOC( ps->DataInf.dwAppPhyBytesPerLine, GFP_KERNEL);
|
ps->Scan.bp.pMonoBuf = _KALLOC( ps->DataInf.dwAppPhyBytesPerLine, GFP_KERNEL);
|
||||||
|
|
||||||
if ( NULL == ps->Scan.bp.pMonoBuf ) {
|
if ( NULL == ps->Scan.bp.pMonoBuf ) {
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"pt_drv%u: Not enough memory available!\n", ps->devno );
|
"pt_drv%u: Not enough memory available!\n", ps->devno );
|
||||||
return _E_ALLOC;
|
return _E_ALLOC;
|
||||||
}
|
}
|
||||||
|
@ -1355,11 +1005,7 @@ static int ptdrvRead( pScanData ps, pUChar buffer, int count )
|
||||||
scaleBuf = _KALLOC( ps->DataInf.dwAppPhyBytesPerLine, GFP_KERNEL);
|
scaleBuf = _KALLOC( ps->DataInf.dwAppPhyBytesPerLine, GFP_KERNEL);
|
||||||
if ( NULL == scaleBuf ) {
|
if ( NULL == scaleBuf ) {
|
||||||
_KFREE( ps->Scan.bp.pMonoBuf );
|
_KFREE( ps->Scan.bp.pMonoBuf );
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"pt_drv%u: Not enough memory available!\n", ps->devno );
|
"pt_drv%u: Not enough memory available!\n", ps->devno );
|
||||||
return _E_ALLOC;
|
return _E_ALLOC;
|
||||||
}
|
}
|
||||||
|
@ -1406,11 +1052,7 @@ static int ptdrvRead( pScanData ps, pUChar buffer, int count )
|
||||||
|
|
||||||
retval = ps->Calibration( ps );
|
retval = ps->Calibration( ps );
|
||||||
if( _OK != retval ) {
|
if( _OK != retval ) {
|
||||||
#ifdef __KERNEL__
|
|
||||||
_PRINT(
|
|
||||||
#else
|
|
||||||
DBG( DBG_HIGH,
|
DBG( DBG_HIGH,
|
||||||
#endif
|
|
||||||
"pt_drv%u: calibration failed, result = %i\n",
|
"pt_drv%u: calibration failed, result = %i\n",
|
||||||
ps->devno, retval );
|
ps->devno, retval );
|
||||||
goto ReadFinished;
|
goto ReadFinished;
|
||||||
|
@ -1507,12 +1149,9 @@ static int ptdrvRead( pScanData ps, pUChar buffer, int count )
|
||||||
ps->Scan.dwLinesToRead--;
|
ps->Scan.dwLinesToRead--;
|
||||||
|
|
||||||
/* needed, esp. to avoid freezing the system in SPP mode */
|
/* needed, esp. to avoid freezing the system in SPP mode */
|
||||||
#ifdef __KERNEL__
|
|
||||||
schedule();
|
|
||||||
/*#else
|
/*#else
|
||||||
sched_yield();
|
sched_yield();
|
||||||
*/
|
*/
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps->fScanningStatus) {
|
if (ps->fScanningStatus) {
|
||||||
|
@ -1565,346 +1204,6 @@ ReadFinished:
|
||||||
return retval;
|
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
|
* here we only have wrapper functions
|
||||||
*/
|
*/
|
||||||
|
@ -1980,6 +1279,4 @@ static int PtDrvRead ( pUChar buffer, int count )
|
||||||
return ptdrvRead( PtDrvDevices[0], buffer, count );
|
return ptdrvRead( PtDrvDevices[0], buffer, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* guard __KERNEL__ */
|
|
||||||
|
|
||||||
/* END PLUSTEK-PP_PTDRV.C ...................................................*/
|
/* END PLUSTEK-PP_PTDRV.C ...................................................*/
|
||||||
|
|
|
@ -63,8 +63,6 @@
|
||||||
#ifndef __PLUSTEK_SCAN_H__
|
#ifndef __PLUSTEK_SCAN_H__
|
||||||
#define __PLUSTEK_SCAN_H__
|
#define __PLUSTEK_SCAN_H__
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
|
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <stdarg.h>
|
# include <stdarg.h>
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
@ -76,19 +74,6 @@
|
||||||
# ifdef HAVE_SYS_IO_H
|
# ifdef HAVE_SYS_IO_H
|
||||||
# include <sys/io.h>
|
# include <sys/io.h>
|
||||||
# endif
|
# endif
|
||||||
#else
|
|
||||||
# include <linux/kernel.h>
|
|
||||||
# include <linux/init.h>
|
|
||||||
# include <linux/version.h>
|
|
||||||
# include "plustek-pp_sysdep.h"
|
|
||||||
# include <linux/delay.h>
|
|
||||||
# include <linux/parport.h>
|
|
||||||
|
|
||||||
#ifdef LINUX_24
|
|
||||||
# include <linux/parport_pc.h>
|
|
||||||
#endif /* LINUX_24 */
|
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
|
||||||
|
|
||||||
/*.............................................................................
|
/*.............................................................................
|
||||||
* driver properties
|
* driver properties
|
||||||
|
@ -104,20 +89,6 @@
|
||||||
# define _OPF ps->IO.fnOut
|
# define _OPF ps->IO.fnOut
|
||||||
# define _IPF ps->IO.fnIn
|
# define _IPF ps->IO.fnIn
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
|
|
||||||
#define _OUTB_CTRL(pSD,port_value) _OPF(port_value,pSD->IO.pbControlPort)
|
|
||||||
#define _OUTB_DATA(pSD,port_value) _OPF(port_value,pSD->IO.pbSppDataPort)
|
|
||||||
#define _OUTB_ECTL(pSD,port_value) _OPF(port_value,(pSD->IO.portBase+0x402))
|
|
||||||
|
|
||||||
#define _INB_CTRL(pSD) _IPF(pSD->IO.pbControlPort)
|
|
||||||
#define _INB_DATA(pSD) _IPF(pSD->IO.pbSppDataPort)
|
|
||||||
#define _INB_EPPDATA(pSD) _IPF(pSD->IO.pbEppDataPort)
|
|
||||||
#define _INB_STATUS(pSD) _IPF(pSD->IO.pbStatusPort)
|
|
||||||
#define _INB_ECTL(pSD) _IPF((pSD->IO.portBase+0x402))
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define _OUTB_CTRL(pSD,port_value) sanei_pp_outb_ctrl(pSD->pardev, port_value)
|
#define _OUTB_CTRL(pSD,port_value) sanei_pp_outb_ctrl(pSD->pardev, port_value)
|
||||||
#define _OUTB_DATA(pSD,port_value) sanei_pp_outb_data(pSD->pardev, port_value)
|
#define _OUTB_DATA(pSD,port_value) sanei_pp_outb_data(pSD->pardev, port_value)
|
||||||
#define _OUTB_ECTL(pSD,port_value)
|
#define _OUTB_ECTL(pSD,port_value)
|
||||||
|
@ -127,32 +98,19 @@
|
||||||
#define _INB_EPPDATA(pSD) sanei_pp_inb_epp(pSD->pardev)
|
#define _INB_EPPDATA(pSD) sanei_pp_inb_epp(pSD->pardev)
|
||||||
#define _INB_STATUS(pSD) sanei_pp_inb_stat(pSD->pardev)
|
#define _INB_STATUS(pSD) sanei_pp_inb_stat(pSD->pardev)
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*.............................................................................
|
/*.............................................................................
|
||||||
* for memory allocation
|
* for memory allocation
|
||||||
*/
|
*/
|
||||||
#ifndef __KERNEL__
|
|
||||||
# define _KALLOC(x,y) malloc(x)
|
# define _KALLOC(x,y) malloc(x)
|
||||||
# define _KFREE(x) free(x)
|
# define _KFREE(x) free(x)
|
||||||
# define _VMALLOC(x) malloc(x)
|
# define _VMALLOC(x) malloc(x)
|
||||||
# define _VFREE(x) free(x)
|
# define _VFREE(x) free(x)
|
||||||
#else
|
|
||||||
# define _KALLOC(x,y) kmalloc(x,y)
|
|
||||||
# define _KFREE(x) kfree(x)
|
|
||||||
# define _VMALLOC(x) vmalloc(x)
|
|
||||||
# define _VFREE(x) vfree(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* WARNING - never use the _SECOND define with the _DODELAY macro !!
|
* WARNING - never use the _SECOND define with the _DODELAY macro !!
|
||||||
* they are for use the MiscStartTimer function and the _DO_UDELAY macro
|
* they are for use the MiscStartTimer function and the _DO_UDELAY macro
|
||||||
*/
|
*/
|
||||||
#ifndef __KERNEL__
|
|
||||||
typedef double TimerDef, *pTimerDef;
|
typedef double TimerDef, *pTimerDef;
|
||||||
#else
|
|
||||||
typedef long long TimerDef, *pTimerDef;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _MSECOND 1000 /* based on 1 us */
|
#define _MSECOND 1000 /* based on 1 us */
|
||||||
#define _SECOND (1000*_MSECOND)
|
#define _SECOND (1000*_MSECOND)
|
||||||
|
@ -160,13 +118,8 @@ typedef long long TimerDef, *pTimerDef;
|
||||||
/*.............................................................................
|
/*.............................................................................
|
||||||
* timer topics
|
* timer topics
|
||||||
*/
|
*/
|
||||||
#ifndef __KERNEL__
|
|
||||||
# define _DO_UDELAY(usecs) sanei_pp_udelay(usecs)
|
# define _DO_UDELAY(usecs) sanei_pp_udelay(usecs)
|
||||||
# define _DODELAY(msecs) { int i; for( i = msecs; i--; ) _DO_UDELAY(1000); }
|
# define _DODELAY(msecs) { int i; for( i = msecs; i--; ) _DO_UDELAY(1000); }
|
||||||
#else
|
|
||||||
# define _DO_UDELAY(usecs) udelay(usecs)
|
|
||||||
# define _DODELAY(msecs) mdelay(msecs)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*.............................................................................
|
/*.............................................................................
|
||||||
* include the shared stuff right here, this concerns the ioctl interface
|
* include the shared stuff right here, this concerns the ioctl interface
|
||||||
|
|
|
@ -143,17 +143,7 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
typedef struct scandata
|
typedef struct scandata
|
||||||
{
|
{
|
||||||
#ifdef __KERNEL__
|
|
||||||
UInt flags; /* as follows: */
|
|
||||||
#define _PTDRV_INITALIZED 0x00000001
|
|
||||||
#define _PTDRV_OPEN 0x00000002
|
|
||||||
|
|
||||||
struct pardevice *pardev; /* for accessing parport... */
|
|
||||||
struct parport *pp;
|
|
||||||
ProcDirDef procDir;
|
|
||||||
#else
|
|
||||||
int pardev; /* parport handle in user-space */
|
int pardev; /* parport handle in user-space */
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* device control
|
* device control
|
||||||
|
|
Ładowanie…
Reference in New Issue