kopia lustrzana https://gitlab.com/sane-project/backends
hp5400 backend: moved constants init to sane_init() and sane_exit()
rodzic
a4e842d946
commit
c8845a70e2
|
@ -1,3 +1,7 @@
|
||||||
|
2003-07-28 Thomas Soumarmon <thomas.soumarmon@cogitae.net>
|
||||||
|
* backend/hp5400_* : moved constant initialization to sane_init
|
||||||
|
and sane_exit + removed some compilation warnings.
|
||||||
|
|
||||||
2003-07-27 Henning Meier-Geinitz <henning@meier-geinitz.de>
|
2003-07-27 Henning Meier-Geinitz <henning@meier-geinitz.de>
|
||||||
|
|
||||||
* Makefile.in backend/Makefile.in doc/Makefile.in
|
* Makefile.in backend/Makefile.in doc/Makefile.in
|
||||||
|
|
|
@ -89,22 +89,38 @@
|
||||||
|
|
||||||
|
|
||||||
typedef struct versionString {
|
typedef struct versionString {
|
||||||
const char strVersion[128];
|
char strVersion[128];
|
||||||
} versionString;
|
} versionString;
|
||||||
|
|
||||||
versionString MatchVersions[] = {
|
|
||||||
{ "SilitekIBlizd C3 ScannerV0.84" } ,
|
|
||||||
{ "SilitekIBlizd C3 ScannerV0.86" } ,
|
|
||||||
{ "SilitekIBlizd C3 ScannerV0.87" }
|
|
||||||
};
|
|
||||||
|
|
||||||
const int numVersions = 3;
|
const int numVersions = 3;
|
||||||
|
versionString *MatchVersions;
|
||||||
|
|
||||||
|
|
||||||
static TScannerModel Model_HP54xx =
|
static TScannerModel Model_HP54xx =
|
||||||
{ "Hewlett-Packard", "HP54xx Flatbed Scanner" };
|
{ "Hewlett-Packard", "HP54xx Flatbed Scanner" };
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
InitHp5400_internal() {
|
||||||
|
|
||||||
|
MatchVersions = malloc( sizeof(versionString) * numVersions );
|
||||||
|
strcpy( MatchVersions[0].strVersion, "SilitekIBlizd C3 ScannerV0.84");
|
||||||
|
strcpy( MatchVersions[1].strVersion, "SilitekIBlizd C3 ScannerV0.86");
|
||||||
|
strcpy( MatchVersions[2].strVersion, "SilitekIBlizd C3 ScannerV0.87");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
FreeHp5400_internal() {
|
||||||
|
|
||||||
|
free(MatchVersions);
|
||||||
|
MatchVersions = NULL;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
WriteByte (int iHandle, int cmd, char data)
|
WriteByte (int iHandle, int cmd, char data)
|
||||||
{
|
{
|
||||||
|
@ -1223,7 +1239,7 @@ HP5400Open (THWParams * params, char *filename)
|
||||||
i = 0;
|
i = 0;
|
||||||
versionMatched = 0;
|
versionMatched = 0;
|
||||||
while ( !versionMatched && (i < numVersions) ) {
|
while ( !versionMatched && (i < numVersions) ) {
|
||||||
if (!memcmp (szVersion + 1, MatchVersions[i] .strVersion, strlen(MatchVersions[i] .strVersion) - 4)) {
|
if (!strncmp (szVersion + 1, MatchVersions[i] .strVersion, strlen(MatchVersions[i] .strVersion) - 4)) {
|
||||||
versionMatched = 1;
|
versionMatched = 1;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -226,6 +226,12 @@ HP5400Detect (char *filename,
|
||||||
char *pszDeviceName));
|
char *pszDeviceName));
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
InitHp5400_internal( void );
|
||||||
|
|
||||||
|
int
|
||||||
|
FreeHp5400_internal( void );
|
||||||
|
|
||||||
|
|
||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
int
|
int
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
#include "sane/sanei_config.h"
|
#include "sane/sanei_config.h"
|
||||||
#include "sane/saneopts.h"
|
#include "sane/saneopts.h"
|
||||||
#include "sane/config.h"
|
#include "sane/config.h"
|
||||||
|
#include "sane/sanei_usb.h"
|
||||||
|
|
||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* memcpy */
|
#include <string.h> /* memcpy */
|
||||||
|
@ -179,10 +180,12 @@ TDevListEntry;
|
||||||
|
|
||||||
|
|
||||||
/* Device filename for USB access */
|
/* Device filename for USB access */
|
||||||
char * usb_devfile = "/dev/usb/scanner0";
|
char usb_devfile[128];
|
||||||
|
|
||||||
static TDevListEntry *_pFirstSaneDev = 0;
|
static TDevListEntry *_pFirstSaneDev = 0;
|
||||||
static int iNumSaneDev = 0;
|
static int iNumSaneDev = 0;
|
||||||
|
|
||||||
|
|
||||||
static const SANE_Device **_pSaneDevList = 0;
|
static const SANE_Device **_pSaneDevList = 0;
|
||||||
|
|
||||||
/* option constraints */
|
/* option constraints */
|
||||||
|
@ -463,6 +466,13 @@ sane_init (SANE_Int * piVersion, SANE_Auth_Callback pfnAuth)
|
||||||
/* prevent compiler from complaing about unused parameters */
|
/* prevent compiler from complaing about unused parameters */
|
||||||
pfnAuth = pfnAuth;
|
pfnAuth = pfnAuth;
|
||||||
|
|
||||||
|
strcpy(usb_devfile, "/dev/usb/scanner0");
|
||||||
|
_pFirstSaneDev = 0;
|
||||||
|
iNumSaneDev = 0;
|
||||||
|
|
||||||
|
InitHp5400_internal();
|
||||||
|
|
||||||
|
|
||||||
DBG_INIT ();
|
DBG_INIT ();
|
||||||
|
|
||||||
HP5400_DBG (DBG_MSG, "sane_init: SANE hp5400 backend version %d.%d-%d (from %s)\n",
|
HP5400_DBG (DBG_MSG, "sane_init: SANE hp5400 backend version %d.%d-%d (from %s)\n",
|
||||||
|
@ -542,6 +552,9 @@ sane_exit (void)
|
||||||
free (_pSaneDevList);
|
free (_pSaneDevList);
|
||||||
_pSaneDevList = 0;
|
_pSaneDevList = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FreeHp5400_internal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -919,7 +932,7 @@ sane_read (SANE_Handle h, SANE_Byte * buf, SANE_Int maxlen, SANE_Int * len)
|
||||||
/* Note: this is already color corrected, though some work still needs to be done
|
/* Note: this is already color corrected, though some work still needs to be done
|
||||||
to deal with the colour offsetting */
|
to deal with the colour offsetting */
|
||||||
TScanner *s;
|
TScanner *s;
|
||||||
char *buffer = buf;
|
char *buffer = (char*)buf;
|
||||||
|
|
||||||
HP5400_DBG (DBG_MSG, "sane_read: request %d bytes \n", maxlen);
|
HP5400_DBG (DBG_MSG, "sane_read: request %d bytes \n", maxlen);
|
||||||
|
|
||||||
|
|
|
@ -253,13 +253,13 @@ hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData)
|
||||||
|
|
||||||
/* returns >0 if command OK */
|
/* returns >0 if command OK */
|
||||||
int
|
int
|
||||||
hp5400_bulk_read (int iHandle, int len, int block, FILE * file)
|
hp5400_bulk_read (int iHandle, size_t len, int block, FILE * file)
|
||||||
{
|
{
|
||||||
int fd;
|
SANE_Int fd;
|
||||||
char x1 = 0x14, x2 = 0x24;
|
char x1 = 0x14, x2 = 0x24;
|
||||||
short buf[4] = { 0, 0, 0, 0 };
|
short buf[4] = { 0, 0, 0, 0 };
|
||||||
unsigned char *buffer;
|
SANE_Byte *buffer;
|
||||||
int res = 0;
|
size_t res = 0;
|
||||||
|
|
||||||
buf[2] = block;
|
buf[2] = block;
|
||||||
|
|
||||||
|
@ -297,8 +297,8 @@ int
|
||||||
hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen,
|
hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen,
|
||||||
void *buffer, int len)
|
void *buffer, int len)
|
||||||
{
|
{
|
||||||
int fd;
|
SANE_Int fd;
|
||||||
int res = 0;
|
size_t res = 0;
|
||||||
|
|
||||||
if (iHandle < 0)
|
if (iHandle < 0)
|
||||||
{
|
{
|
||||||
|
@ -309,7 +309,7 @@ hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen,
|
||||||
|
|
||||||
_UsbWriteControl (fd, iCmd, 0, cmd, cmdlen);
|
_UsbWriteControl (fd, iCmd, 0, cmd, cmdlen);
|
||||||
res = len;
|
res = len;
|
||||||
sanei_usb_read_bulk (fd, buffer, &res);
|
sanei_usb_read_bulk (fd, (SANE_Byte *) buffer, &res);
|
||||||
HP5400_DBG (DBG_MSG, "Read block returned %d when reading %d\n", res, len);
|
HP5400_DBG (DBG_MSG, "Read block returned %d when reading %d\n", res, len);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -319,8 +319,8 @@ int
|
||||||
hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen,
|
hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen,
|
||||||
int datalen, int block, char *data)
|
int datalen, int block, char *data)
|
||||||
{
|
{
|
||||||
int fd;
|
SANE_Int fd;
|
||||||
int res = 0, offset = 0;
|
size_t res = 0, offset = 0;
|
||||||
|
|
||||||
if (iHandle < 0)
|
if (iHandle < 0)
|
||||||
{
|
{
|
||||||
|
@ -346,7 +346,7 @@ hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen,
|
||||||
HP5400_DBG (DBG_MSG, "\n");
|
HP5400_DBG (DBG_MSG, "\n");
|
||||||
}
|
}
|
||||||
res = (datalen < block) ? datalen : block;
|
res = (datalen < block) ? datalen : block;
|
||||||
sanei_usb_write_bulk (fd, data + offset, &res);
|
sanei_usb_write_bulk (fd, (SANE_Byte *) (data + offset), &res);
|
||||||
HP5400_DBG (DBG_MSG, "Write returned %d, %d remain\n", res, datalen);
|
HP5400_DBG (DBG_MSG, "Write returned %d, %d remain\n", res, datalen);
|
||||||
datalen -= block;
|
datalen -= block;
|
||||||
offset += block;
|
offset += block;
|
||||||
|
|
|
@ -86,7 +86,7 @@ int hp5400_command_read (int iHandle, int iCmd, int iLen, void *pbData);
|
||||||
int hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData);
|
int hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData);
|
||||||
|
|
||||||
/* returns >0 if command OK */
|
/* returns >0 if command OK */
|
||||||
int hp5400_bulk_read (int iHandle, int len, int block, FILE * file);
|
int hp5400_bulk_read (int iHandle, size_t len, int block, FILE * file);
|
||||||
|
|
||||||
/* returns >0 if command OK */
|
/* returns >0 if command OK */
|
||||||
int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen,
|
int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen,
|
||||||
|
|
|
@ -63,7 +63,7 @@ int hp5400_command_read_noverify (int iHandle, int iCmd, int iLen,
|
||||||
int hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData);
|
int hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData);
|
||||||
void hp5400_command_write_noverify (int fd, int iValue, void *pabData,
|
void hp5400_command_write_noverify (int fd, int iValue, void *pabData,
|
||||||
int iSize);
|
int iSize);
|
||||||
int hp5400_bulk_read (int iHandle, int size, int block, FILE * file);
|
int hp5400_bulk_read (int iHandle, size_t size, int block, FILE * file);
|
||||||
int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen,
|
int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen,
|
||||||
void *buffer, int len);
|
void *buffer, int len);
|
||||||
int hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen,
|
int hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen,
|
||||||
|
|
Ładowanie…
Reference in New Issue