[Hp5400backend-cvs-update] hp5400/hp5400 hp5400_debug.c,NONE,1.1 hp5400_debug.h,NONE,1.1 hp5400_inte
Status: Alpha
Brought to you by:
soumarmt
Update of /cvsroot/hp5400backend/hp5400/hp5400 In directory sc8-pr-cvs1:/tmp/cvs-serv28907 Modified Files: INSTALL.txt Makefile TODO.txt hp5400.c hp5400.conf hp5400.desc hp5400.h hp5400_scanner.c hp5400_xfer.h releaseNotes.txt sane-hp5400.c Added Files: hp5400_debug.c hp5400_debug.h hp5400_internal.h hp5400_sanei.h hp5400_scanner.h Log Message: *retrieved changes from SANE 1.0.12 backend package\n*fixed compilation\n*fixed copyrights --- NEW FILE: hp5400_debug.c --- /* sane - Scanner Access Now Easy. Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> Copyright (C) 2003 Thomas Soumarmon <tho...@co...> Originally copied from HP3300 testtools. Original notice follows: Copyright (C) 2001 Bertrik Sikken (be...@zo...) This file is part of the SANE package. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "hp5400_debug.h" #ifdef LOCAL_DBG /* Debug messages levels */ #include <stdio.h> FILE *DBG_ASSERT = NULL; FILE *DBG_ERR = NULL; FILE *DBG_MSG = NULL; #endif void hp5400_dbg_start() { #ifdef LOCAL_DBG DBG_MSG = stdout; DBG_ERR = stderr; DBG_ASSERT = stderr; #endif } --- NEW FILE: hp5400_debug.h --- #ifndef __HP5400_DEBUG_H_ #define __HP5400_DEBUG_H_ /* sane - Scanner Access Now Easy. Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> Copyright (C) 2003 Thomas Soumarmon <tho...@co...> Originally copied from HP3300 testtools. Original notice follows: Copyright (C) 2001 Bertrik Sikken (be...@zo...) This file is part of the SANE package. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef STANDALONE #include <sane/sanei_debug.h> #define DBG_ASSERT 1 #define DBG_ERR 16 #define DBG_MSG 32 #define HP5400_DBG DBG #else #include <stdio.h> #define LOCAL_DBG #define HP5400_DBG fprintf extern FILE *DBG_ASSERT; extern FILE *DBG_ERR; extern FILE *DBG_MSG; #endif void hp5400_dbg_start(); #endif --- NEW FILE: hp5400_internal.h --- #ifndef _HP5400_INTERNAL_H_ #define _HP5400_INTERNAL_H_ /* sane - Scanner Access Now Easy. (C) 2003 Thomas Soumarmon <tho...@co...> (c) 2003 Martijn van Oosterhout, kl...@sv... (c) 2002 Bertrik Sikken, be...@zo... This file is part of the SANE package. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. HP5400/5470 Test util. Currently is only able to read back the scanner version string, but this basically demonstrates ability to communicate with the scanner. Massively expanded. Can do calibration scan, upload gamma and calibration tables and stores the results of a scan. - 19/02/2003 Martijn */ #ifdef __GNUC__ #define PACKED __attribute__ ((packed)) #else #define PACKED #endif /* If this is enabled, a copy of the raw data from the scanner will be saved to imagedebug.dat and the attempted conversion to imagedebug.ppm */ /* #define IMAGE_DEBUG */ /* If this is defined you get extra info on the calibration */ /* #define CALIB_DEBUG */ #define CMD_GETVERSION 0x1200 #define CMD_GETUITEXT 0xf00b #define CMD_GETCMDID 0xc500 #define CMD_SCANREQUEST 0x2505 /* This is for previews */ #define CMD_SCANREQUEST2 0x2500 /* This is for real scans */ #define CMD_SCANRESPONSE 0x3400 /* Testing stuff to make it work */ #define CMD_SETDPI 0x1500 /* ??? */ #define CMD_STOPSCAN 0x1B01 /* 0x40 = lamp in on, 0x00 = lamp is off */ #define CMD_STARTSCAN 0x1B05 /* 0x40 = lamp in on, 0x00 = lamp is off */ #define CMD_UNKNOWN 0x2300 /* Send fixed string */ #define CMD_UNKNOWN2 0xD600 /* ??? Set to 0x04 */ #define CMD_UNKNOWN3 0xC000 /* ??? Set to 02 03 03 3C */ #define CMD_SETOFFSET 0xE700 /* two ints in network order. X-offset, Y-offset of full scan */ /* Given values seem to be 0x0054 (=4.57mm) and 0x0282 (=54.36mm) */ #define CMD_INITBULK1 0x0087 /* send 0x14 */ #define CMD_INITBULK2 0x0083 /* send 0x24 */ #define CMD_INITBULK3 0x0082 /* transfer length 0xf000 */ struct ScanRequest { u_int8_t x1; /* Set to 0x08 */ u_int16_t dpix, dpiy; /* Set to 75, 150 or 300 in network order */ u_int16_t offx, offy; /* Offset to scan, in 1/300th of dpi, in network order */ u_int16_t lenx, leny; /* Size of scan, in 1/300th of dpi, in network order */ u_int16_t flags1, flags2, flags3; /* Undetermined flag info */ /* Known combinations are: 1st calibration scan: 0x0000, 0x0010, 0x1820 = 24bpp 2nd calibration scan: 0x0000, 0x0010, 0x3020 = 48bpp ??? 3rd calibration scan: 0x0000, 0x0010, 0x3024 = 48bpp ??? Preview scan: 0x0080, 0x0000, 0x18E8 = 8bpp 4th & 5th like 2nd and 3rd B&W scan: 0x0080, 0x0040, 0x08E8 = 8bpp 6th & 7th like 2nd and 3rd True colour scan 0x0080, 0x0040, 0x18E8 = 24bpp */ u_int8_t zero; /* Seems to always be zero */ u_int16_t gamma[3]; /* Set to 100 in network order. Gamma? */ u_int16_t pad[3]; /* Zero padding ot 32 bytes??? */ } PACKED; /* More known combos (All 24-bit): 300 x 300 light calibration: 0x0000, 0x0010, 0x1820 300 x 300 dark calibration: 0x0000, 0x0010, 0x3024 75 x 75 preview scan: 0x0080, 0x0000, 0x18E8 300 x 300 full scan: 0x0080, 0x0000, 0x18E8 600 x 300 light calibration: 0x0000, 0x0010, 0x3000 600 x 300 dark calibration: 0x0000, 0x0010, 0x3004 600 x 600 full scan: 0x0080, 0x0000, 0x18C8 1200 x 300 light calibration: 0x0000, 0x0010, 0x3000 1200 x 300 dark calibration: 0x0000, 0x0010, 0x3004 1200 x 1200 full scan: 0x0080, 0x0000, 0x18C8 2400 x 300 light calibration: 0x0000, 0x0010, 0x3000 2400 x 300 dark calibration: 0x0000, 0x0010, 0x3004 2400 x 2400 full scan: 0x0080, 0x0000, 0x18C0 */ struct ScanResponse { u_int16_t x1; /* Usually 0x0000 or 0x4000 */ u_int32_t transfersize; /* Number of bytes to be transferred */ u_int32_t xsize; /* Shape of returned bitmap */ u_int16_t ysize; /* Why does the X get more bytes? */ u_int16_t pad[2]; /* Zero padding to 16 bytes??? */ } PACKED; int InitScan2 (enum ScanType type, struct ScanRequest *req, THWParams * pHWParams, struct ScanResponse *res, int iColourOffset, int code); void FinishScan (THWParams * pHWParams); int WriteByte (int iHandle, int cmd, char data); int SetLamp (THWParams * pHWParams, int fLampOn); int WarmupLamp (int iHandle); int SetCalibration (int iHandle, int numPixels, unsigned int *low_vals[3], unsigned int *high_vals[3], int dpi); void WriteGammaCalibTable (int iHandle, const int *pabGammaR, const int *pabGammaG, const int *pabGammaB); void SetDefaultGamma (int iHandle); void CircBufferInit (int iHandle, TDataPipe * p, int iBytesPerLine, int bpp, int iMisAlignment, int blksize, int iTransferSize); int CircBufferGetLine (int iHandle, TDataPipe * p, void *pabLine); void CircBufferExit (TDataPipe * p); void DecodeImage (FILE * file, int planes, int bpp, int xsize, int ysize, const char *filename); int hp5400_test_scan_response (struct ScanResponse *resp, struct ScanRequest *req); int DoAverageScan (int iHandle, struct ScanRequest *req, int code, unsigned int **array); int DoScan (int iHandle, struct ScanRequest *req, const char *filename, int code, struct ScanResponse *res); int Calibrate (int iHandle, int dpi); int hp5400_scan (int iHandle, TScanParams * params, THWParams * pHWParams, const char *filename); int PreviewScan (int iHandle); int InitScanner (int iHandle); int InitScan (enum ScanType scantype, TScanParams * pParams, THWParams * pHWParams); void FinishScan (THWParams * pHWParams); int HP5400Open (THWParams * params, char *filename); void HP5400Close (THWParams * params); int HP5400Detect (char *filename, int (*_ReportDevice) (TScannerModel * pModel, char *pszDeviceName)); #ifdef STANDALONE int main (int argc, char *argv[]); #endif #endif --- NEW FILE: hp5400_sanei.h --- #ifndef _HP5400_SANEI_H_ #define _HP5400_SANEI_H_ /* sane - Scanner Access Now Easy. Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> Copyright (C) 2003 Thomas Soumarmon <tho...@co...> Copyright (c) 2003 Henning Meier-Geinitz, <he...@me...> Originally copied from HP3300 testtools. Original notice follows: Copyright (C) 2001 Bertrik Sikken (be...@zo...) This file is part of the SANE package. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Transport layer for communication with HP5400/5470 scanner. Implementation using sanei_usb Additions to support bulk data transport. Added debugging info - 19/02/2003 Martijn Changed to use sanei_usb instead of direct /dev/usb/scanner access - 15/04/2003 Henning */ #define CMD_INITBULK1 0x0087 /* send 0x14 */ #define CMD_INITBULK2 0x0083 /* send 0x24 */ #define CMD_INITBULK3 0x0082 /* transfer length 0xf000 */ void _UsbWriteControl (int fd, int iValue, int iIndex, void *pabData, int iSize); void hp5400_command_write_noverify (int fd, int iValue, void *pabData, int iSize); void _UsbReadControl (int fd, int iValue, int iIndex, void *pabData, int iSize); int hp5400_open (const char *filename); void hp5400_close (int iHandle); /* returns value > 0 if verify ok */ int hp5400_command_verify (int iHandle, int iCmd); /* returns > 0 if command OK */ int hp5400_command_read_noverify (int iHandle, int iCmd, int iLen, void *pbData); /* returns > 0 if command OK */ int hp5400_command_read (int iHandle, int iCmd, int iLen, void *pbData); /* returns >0 if command OK */ int hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData); /* returns >0 if command OK */ int hp5400_bulk_read (int iHandle, int len, int block, FILE * file); /* returns >0 if command OK */ int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen, void *buffer, int len); /* returns >0 if command OK */ int hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen, int datalen, int block, char *data); /** ScannerIsOn retrieve on/off status from scanner @return 1 if is on 0 if is off -1 if is not reachable */ int hp5400_isOn (int iHandle); #endif --- NEW FILE: hp5400_scanner.h --- #ifndef _HP5400_SCANNER_H_ #define _HP5400_SCANNER_H_ /* sane - Scanner Access Now Easy. Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> Copyright (C) 2003 Thomas Soumarmon <tho...@co...> Originally copied from HP3300 testtools. Original notice follows: Copyright (C) 2001 Bertrik Sikken (be...@zo...) This file is part of the SANE package. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Transport layer for communication with HP5400/5470 scanner. Implementation using the Linux 'scanner' driver module Additions to support bulk data transport. Added debugging info - 19/02/2003 Martijn */ #include <asm/types.h> /* types used in ioctls */ #define CMD_INITBULK1 0x0087 /* send 0x14 */ #define CMD_INITBULK2 0x0083 /* send 0x24 */ #define CMD_INITBULK3 0x0082 /* transfer length 0xf000 */ /* copied from usb.h */ #define SCANNER_IOCTL_VENDOR _IOR('U', 0x20, int) #define SCANNER_IOCTL_PRODUCT _IOR('U', 0x21, int) #define SCANNER_IOCTL_CTRLMSG _IOWR('U', 0x22, devrequest) typedef struct { __u8 requesttype; __u8 request; __u16 value; __u16 index; __u16 length; } devrequest __attribute__ ((packed)); void _UsbWriteControl(int fd, int iValue, int iIndex, void *pabData, int iSize); void hp5400_command_write_noverify( int fd, int iValue, void *pabData, int iSize); void _UsbReadControl(int fd, int iValue, int iIndex, void *pabData, int iSize); int hp5400_open(const char* filename); void hp5400_close(int iHandle); /* returns value > 0 if verify ok */ int hp5400_command_verify(int iHandle, int iCmd); /* returns > 0 if command OK */ int hp5400_command_read_noverify(int iHandle, int iCmd, int iLen, void *pbData); /* returns > 0 if command OK */ int hp5400_command_read(int iHandle, int iCmd, int iLen, void *pbData); /* returns >0 if command OK */ int hp5400_command_write(int iHandle, int iCmd, int iLen, void *pbData); /* returns >0 if command OK */ int hp5400_bulk_read(int iHandle, int len, int block, FILE *file ); /* returns >0 if command OK */ int hp5400_bulk_read_block(int iHandle, int iCmd, void *cmd, int cmdlen, void *buffer, int len ); /* returns >0 if command OK */ int hp5400_bulk_command_write(int iHandle, int iCmd, void *cmd, int cmdlen, int datalen, int block, char *data ); /** ScannerIsOn retrieve on/off status from scanner @return 1 if is on 0 if is off -1 if is not reachable */ int hp5400_isOn( int iHandle ); #endif Index: INSTALL.txt =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/INSTALL.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** INSTALL.txt 25 Feb 2003 21:30:27 -0000 1.2 --- INSTALL.txt 26 May 2003 13:46:15 -0000 1.3 *************** *** 10,15 **** To install this backend you have to : ! 1. compile and install sane-backend (version 1.0.10 or 1.0.11 suggested) ! you can get on SANE website. 2. modify the Makefile to set SANE_BACKEND_SRC and SANE_LIBS_DIR to fit your configuration --- 10,15 ---- To install this backend you have to : ! 1. compile and install sane-backend (version 1.0.10, 1.0.11 or 1.0.12 ! suggested) you can get it from SANE website. 2. modify the Makefile to set SANE_BACKEND_SRC and SANE_LIBS_DIR to fit your configuration *************** *** 23,25 **** As it is alpha code, it is far to be full featured and it is still really buggy. If you want to suggest corrections or modifications in the code, ! fill free to contact Thomas Soumarmon <sou...@ne...> --- 23,25 ---- As it is alpha code, it is far to be full featured and it is still really buggy. If you want to suggest corrections or modifications in the code, ! feel free to contact Thomas Soumarmon <sou...@ne...> Index: Makefile =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 7 Mar 2003 22:42:07 -0000 1.5 --- Makefile 26 May 2003 13:46:15 -0000 1.6 *************** *** 1,9 **** # $Id$ # # path for sane-backend source (to find the includes needed) # ! #SANE_BACKEND_SRC=/usr/local/src/sane-backends-1.0.11 ! SANE_BACKEND_SRC=/home/kleptog/debian/sane-backends-1.0.10 # --- 1,12 ---- # $Id$ + # Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> + # Copyright (C) 2003 Thomas Soumarmon <tho...@co...> + # # path for sane-backend source (to find the includes needed) # ! SANE_BACKEND_SRC=/usr/local/src/sane/sane-backends-1.0.12 ! #SANE_BACKEND_SRC=/home/kleptog/debian/sane-backends-1.0.10 # *************** *** 17,21 **** CC = gcc CFLAGS = -Wall -O2 -g -DV_MAJOR=1 -DV_MINOR=0 -fPIC -I$(SANE_BACKEND_SRC)/include ! LDFLAGS = -lm # uncomment this line if you want to remove the version string match test --- 20,25 ---- CC = gcc CFLAGS = -Wall -O2 -g -DV_MAJOR=1 -DV_MINOR=0 -fPIC -I$(SANE_BACKEND_SRC)/include ! LDFLAGS = -lm -I$(SANE_BACKEND_SRC)/include ! #LDFLAGS = -lm fPIC -I$(SANE_BACKEND_SRC)/include # uncomment this line if you want to remove the version string match test *************** *** 31,38 **** EXEC = $(PKG_NAME) ! LIBTARGET = sane-hp5400.so ! SANE_PKG_LIB =libsane-$(PKG_NAME).so.1 ! OBJECTS = hp5400_scanner.o hp5400.o all: $(EXEC) $(LIBTARGET) --- 35,44 ---- EXEC = $(PKG_NAME) ! LIBTARGET = sane-$(PKG_NAME).so ! SANE_PKG_LIB = libsane-$(PKG_NAME).so.1 ! SANE_FLAGS=-DBACKEND_NAME=$(PKG_NAME) -DV_MAJOR=1 -DV_MINOR=0 -DBUILD=2 ! OBJECTS = $(PKG_NAME)_debug.c $(PKG_NAME)_internal.c $(PKG_NAME)_scanner.c $(PKG_NAME).c ! LIB_OBJECTS = $(PKG_NAME)_debug.c $(PKG_NAME)_internal.c sane-$(PKG_NAME).c $(PKG_NAME)_sanei.c all: $(EXEC) $(LIBTARGET) *************** *** 41,54 **** $(EXEC): $(OBJECTS) ! $(CC) $(LDFLAGS) -o $(EXEC) $(OBJECTS) ! ! hp5400.o: hp5400.c ! $(CC) $(CFLAGS) -c -DSTANDALONE -o $@ $< ! hp5400_scanner.o: hp5400_scanner.c ! $(CC) $(CFLAGS) -c -DSTANDALONE -o $@ $< - $(LIBTARGET): sane-hp5400.o - $(CC) $(LDFLAGS) -shared -fPIC -Wl,-soname -Wl,libsane.so.1 -o $(LIBTARGET) $< .PHONY: clean --- 47,55 ---- $(EXEC): $(OBJECTS) ! $(CC) $(LDFLAGS) -DSTANDALONE -o $(EXEC) $(OBJECTS) ! $(LIBTARGET): $(LIB_OBJECTS) ! $(CC) $(LDFLAGS) $(SANE_FLAGS) -shared -fPIC -Wl,-soname -Wl,libsane.so.1 -o $(LIBTARGET) $< .PHONY: clean Index: TODO.txt =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/TODO.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TODO.txt 27 Feb 2003 13:23:09 -0000 1.7 --- TODO.txt 26 May 2003 13:46:15 -0000 1.8 *************** *** 2,10 **** Here are some points that could be better (hope the list will reach 0 size) : - * There still exist some image decoding troubles that you can see trying a small scan in 600 dpi, but that will probably be found a little bit further. * ability to set pixel depth (8, 16, 24, 32 and 48) - * little noise when scanning small area (canceled twice ?) (MvO: Nope, doesn't fix it) * UI setup is done in English and can be done for other languages. (I've seen some time ago how to do that.) - * remove all C++ comments to replace them by C comments (/**/) * follow the SANE guide to make it OS-independant * check usage of htons (htonl) instead of ntohs (ntohl) maybe should use custom macro to be platform dependant --- 2,7 ---- *************** *** 21,25 **** MvO: * fix gamma tables ! Fixed the missing break that was causing the gamma tables to crash. They are also now loaded into the scanner, Do they work??? --- 18,22 ---- MvO: * fix gamma tables ! Fixed the missing break that was causing the gamma tables to crash. They are also now loaded into the scanner, Do they work??? *************** *** 32,33 **** --- 29,39 ---- MvO: * compute calibration array Added calibration stuff. I'm just using 10^9 / max_value but it seems to work pretty good. + + TS: * There still exist some image decoding troubles that you can see trying a small scan in 600 dpi, + Fixed by Martijn + + TS: * little noise when scanning small area + Fixed by Martijn + + TS: * remove all C++ comments to replace them by C comments (/**/) + Done \ No newline at end of file Index: hp5400.c =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** hp5400.c 11 Mar 2003 10:35:02 -0000 1.22 --- hp5400.c 26 May 2003 13:46:15 -0000 1.23 *************** *** 1,1239 **** ! /* ! (c) 2003 Martijn van Oosterhout, kl...@sv... ! (c) 2002 Bertrik Sikken, be...@zo... ! ! HP5400/5470 Test util. ! Currently is only able to read back the scanner version string, ! but this basically demonstrates ability to communicate with the scanner. ! ! Massively expanded. Can do calibration scan, upload gamma and calibration ! tables and stores the results of a scan. - 19/02/2003 Martijn [...1308 lines suppressed...] ! #include "hp5400_internal.h" ! #include "hp5400_sanei.h" ! /* other definitions */ ! #define TRUE 1 ! #define FALSE 0 ! #define MM_TO_PIXEL(_mm_, _dpi_) ((_mm_) * (_dpi_) / 25.4) ! #define PIXEL_TO_MM(_pixel_, _dpi_) ((_pixel_) * 25.4 / (_dpi_)) ! #define NUM_GAMMA_ENTRIES 65536 ! /* Device filename for USB access */ ! static char *usb_devfile = "/dev/usb/scanner0"; Index: hp5400.conf =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400.conf,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** hp5400.conf 25 Feb 2003 10:01:27 -0000 1.1 --- hp5400.conf 26 May 2003 13:46:15 -0000 1.2 *************** *** 1,9 **** # Device filename to use for scanner access - # Uncomment the following line if you are using the SANE backend - # and want to use the kernel scanner module instead of libusb: # ! #Linux: ! #/dev/usbscanner # ! #FreeBSD/NetBSD: ! #/dev/uscanner0 --- 1,14 ---- + # hp5400.conf + # See man sane-hp5400 for a description. + # + # HP 5400C + usb 0x03F0 0x1005 + # + # HP 5470C + usb 0x03F0 0x1105 + # # Device filename to use for scanner access # ! # Uncomment the following line if autodetection fails # ! #/dev/usbscanner Index: hp5400.desc =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400.desc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** hp5400.desc 26 Feb 2003 12:26:12 -0000 1.2 --- hp5400.desc 26 May 2003 13:46:15 -0000 1.3 *************** *** 11,15 **** :backend "hp5400" ; name of backend ! :version "(0.1)" ; version of backend :status :alpha ; :alpha, :beta, :stable, :new ;:manpage "sane-hp5400" ; name of manpage (if it exists) --- 11,15 ---- :backend "hp5400" ; name of backend ! :version "(0.1)" ; version of backend :status :alpha ; :alpha, :beta, :stable, :new ;:manpage "sane-hp5400" ; name of manpage (if it exists) Index: hp5400.h =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** hp5400.h 10 Mar 2003 11:16:41 -0000 1.9 --- hp5400.h 26 May 2003 13:46:15 -0000 1.10 *************** *** 1,26 **** ! /* ! Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> ! ! Originally copied from HP3300 testtools. Original notice follows: ! ! Copyright (C) 2001 Bertrik Sikken (be...@zo...) ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! $Id$ */ /* Core HP5400 functions. --- 1,51 ---- ! /* sane - Scanner Access Now Easy. ! Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> ! Copyright (C) 2003 Thomas Soumarmon <tho...@co...> ! Originally copied from HP3300 testtools. Original notice follows: ! Copyright (C) 2001 Bertrik Sikken (be...@zo...) ! This file is part of the SANE package. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! ! As a special exception, the authors of SANE give permission for ! additional uses of the libraries contained in this release of SANE. ! ! The exception is that, if you link a SANE library with other files ! to produce an executable, this does not by itself cause the ! resulting executable to be covered by the GNU General Public ! License. Your use of that executable is in no way restricted on ! account of linking the SANE library code into it. ! ! This exception does not, however, invalidate any other reasons why ! the executable file might be covered by the GNU General Public ! License. ! ! If you submit changes to SANE to the maintainers to be included in ! a subsequent release, you agree by submitting the changes that ! those changes may be distributed with this exception intact. ! ! If you write modifications of your own for SANE, it is your choice ! whether to permit this exception to apply to your modifications. ! If you do not wish that, delete this exception notice. ! ! $Id$ */ + /* Core HP5400 functions. *************** *** 33,40 **** #include <unistd.h> ! #include "hp5400_xfer.h" /* for EScannerModel */ ! #define HW_DPI 300 /* horizontal resolution of hardware */ ! #define HW_LPI 300 /* vertical resolution of hardware */ enum ScanType --- 58,65 ---- #include <unistd.h> ! #include "hp5400_xfer.h" /* for EScannerModel */ ! #define HW_DPI 300 /* horizontal resolution of hardware */ ! #define HW_LPI 300 /* vertical resolution of hardware */ enum ScanType *************** *** 42,81 **** SCAN_TYPE_CALIBRATION, SCAN_TYPE_PREVIEW, ! SCAN_TYPE_NORMAL, }; /* In case we ever need to track multiple models */ ! typedef struct { char *pszVendor; char *pszName; ! } TScannerModel; ! typedef struct { /* transfer buffer */ ! void *buffer; /* Pointer to memory allocated for buffer */ ! int roff, goff, boff; /* Offset into buffer of rows to be copied *next* */ ! int bufstart, bufend; /* What is currently the valid buffer */ ! int bpp; /* Bytes per pixel per colour (1 or 2) */ ! int linelength, pixels; /* Bytes per line from scanner */ ! int transfersize; /* Number of bytes to transfer resulting image */ ! int blksize; /* Size of blocks to pull from scanner */ ! int buffersize; /* Size of the buffer */ ! } TDataPipe; ! typedef struct { ! int iXferHandle; /* handle used for data transfer to HW */ ! TDataPipe pipe; /* Pipe for data */ ! ! int iTopLeftX; /* in mm */ ! int iTopLeftY; /* in mm */ ! /* int iSensorSkew; */ /* in units of 1/1200 inch */ ! /* int iSkipLines; */ /* lines of garbage to skip */ ! /* int fReg07; */ /* NIASH00019 */ ! /* int fGamma16; */ /* if TRUE, gamma entries are 16 bit */ /* int iExpTime; */ ! /* int iReversedHead; */ /* Head is reversed */ ! /* int iBufferSize; */ /* Size of internal scan buffer */ /* EScannerModel eModel; */ ! } THWParams; /* The scanner needs a Base DPI off which all it's calibration and --- 67,112 ---- SCAN_TYPE_CALIBRATION, SCAN_TYPE_PREVIEW, ! SCAN_TYPE_NORMAL }; /* In case we ever need to track multiple models */ ! typedef struct ! { char *pszVendor; char *pszName; ! } ! TScannerModel; ! typedef struct ! { /* transfer buffer */ ! void *buffer; /* Pointer to memory allocated for buffer */ ! int roff, goff, boff; /* Offset into buffer of rows to be copied *next* */ ! int bufstart, bufend; /* What is currently the valid buffer */ ! int bpp; /* Bytes per pixel per colour (1 or 2) */ ! int linelength, pixels; /* Bytes per line from scanner */ ! int transfersize; /* Number of bytes to transfer resulting image */ ! int blksize; /* Size of blocks to pull from scanner */ ! int buffersize; /* Size of the buffer */ ! } ! TDataPipe; ! typedef struct ! { ! int iXferHandle; /* handle used for data transfer to HW */ ! TDataPipe pipe; /* Pipe for data */ ! ! int iTopLeftX; /* in mm */ ! int iTopLeftY; /* in mm */ ! /* int iSensorSkew; *//* in units of 1/1200 inch */ ! /* int iSkipLines; *//* lines of garbage to skip */ ! /* int fReg07; *//* NIASH00019 */ ! /* int fGamma16; *//* if TRUE, gamma entries are 16 bit */ /* int iExpTime; */ ! /* int iReversedHead; *//* Head is reversed */ ! /* int iBufferSize; *//* Size of internal scan buffer */ /* EScannerModel eModel; */ ! } ! THWParams; /* The scanner needs a Base DPI off which all it's calibration and *************** *** 87,125 **** ! typedef struct { ! int iDpi; /* horizontal resolution */ ! int iLpi; /* vertical resolution */ ! int iTop; /* in HW coordinates (units HW_LPI) */ ! int iLeft; /* in HW coordinates (units HW_LPI) */ ! int iWidth; /* in HW coordinates (units HW_LPI) */ ! int iHeight; /* in HW coordinates (units HW_LPI) */ ! ! int iBytesPerLine; /* Resulting bytes per line */ ! int iLines; /* Resulting lines of image */ ! int iLinesRead; /* Lines of image already read */ ! ! int iColourOffset; /* How far the colours are offset. Currently this is ! * set by the caller. This doesn't seem to be ! * necessary anymore since the scanner is doing it ! * internally. Leave it for the time being as it ! * may be needed later. */ ! } TScanParams; ! ! ! int HP5400Open(THWParams *pHWParams, char *pszName); ! void HP5400Close(THWParams *pHWParams); ! ! void DumpHex(void *pabData, int iLen, int iWidth); ! void WriteGammaCalibTable( int iHandle, const int *pabGammaR, const int *pabGammaG, const int *pabGammaB ); ! void CircBufferInit(int iHandle, TDataPipe *p, int iBytesPerLine, ! int bpp, int iMisAlignment, int blksize, int iTransferSize ); ! int CircBufferGetLine(int iHandle, TDataPipe *p, void *pabLine ); - void CircBufferExit(TDataPipe *p); - int HP5400Detect( char *filename, int (*_ReportDevice)(TScannerModel *pModel, char *pszDeviceName) ); #endif /* NO _HP5400_H_ */ - --- 118,143 ---- ! typedef struct ! { ! int iDpi; /* horizontal resolution */ ! int iLpi; /* vertical resolution */ ! int iTop; /* in HW coordinates (units HW_LPI) */ ! int iLeft; /* in HW coordinates (units HW_LPI) */ ! int iWidth; /* in HW coordinates (units HW_LPI) */ ! int iHeight; /* in HW coordinates (units HW_LPI) */ ! int iBytesPerLine; /* Resulting bytes per line */ ! int iLines; /* Resulting lines of image */ ! int iLinesRead; /* Lines of image already read */ ! int iColourOffset; /* How far the colours are offset. Currently this is ! * set by the caller. This doesn't seem to be ! * necessary anymore since the scanner is doing it ! * internally. Leave it for the time being as it ! * may be needed later. */ ! } ! TScanParams; #endif /* NO _HP5400_H_ */ Index: hp5400_scanner.c =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400_scanner.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** hp5400_scanner.c 10 Mar 2003 11:13:23 -0000 1.5 --- hp5400_scanner.c 26 May 2003 13:46:15 -0000 1.6 *************** *** 1,10 **** ! /* ! (c) 2003 Martijn van Oosterhout, kl...@sv... ! (c) 2002 Bertrik Sikken, be...@zo... Transport layer for communication with HP5400/5470 scanner. Implementation using the Linux 'scanner' driver module ! Additions to support bulk data transport. Added debugging info - 19/02/2003 Martijn */ --- 1,51 ---- ! /* sane - Scanner Access Now Easy. ! Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> ! Copyright (C) 2003 Thomas Soumarmon <tho...@co...> ! ! Originally copied from HP3300 testtools. Original notice follows: ! ! Copyright (C) 2001 Bertrik Sikken (be...@zo...) ! ! This file is part of the SANE package. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! ! As a special exception, the authors of SANE give permission for ! additional uses of the libraries contained in this release of SANE. ! ! The exception is that, if you link a SANE library with other files ! to produce an executable, this does not by itself cause the ! resulting executable to be covered by the GNU General Public ! License. Your use of that executable is in no way restricted on ! account of linking the SANE library code into it. ! ! This exception does not, however, invalidate any other reasons why ! the executable file might be covered by the GNU General Public ! License. ! ! If you submit changes to SANE to the maintainers to be included in ! a subsequent release, you agree by submitting the changes that ! those changes may be distributed with this exception intact. ! ! If you write modifications of your own for SANE, it is your choice ! whether to permit this exception to apply to your modifications. ! If you do not wish that, delete this exception notice. Transport layer for communication with HP5400/5470 scanner. Implementation using the Linux 'scanner' driver module ! Additions to support bulk data transport. Added debugging info - 19/02/2003 Martijn */ *************** *** 15,19 **** #include <stdlib.h> ! #include "hp5400_xfer.h" #include <asm/types.h> /* types used in ioctls */ --- 56,62 ---- #include <stdlib.h> ! #include "hp5400_xfer.h" /* transfert functions */ ! #include "hp5400_debug.h" /* debug functions */ ! #include "hp5400_scanner.h" /* scanner functions */ #include <asm/types.h> /* types used in ioctls */ *************** *** 21,49 **** #include <linux/usb.h> /* linux usb ioctls */ - #ifdef STANDALONE - #define DBG fprintf - #define DBG_MSG stdout - #define DBG_ERR stderr - #endif - - #define CMD_INITBULK1 0x0087 /* send 0x14 */ - #define CMD_INITBULK2 0x0083 /* send 0x24 */ - #define CMD_INITBULK3 0x0082 /* transfer length 0xf000 */ - /* copied from usb.h */ - #define SCANNER_IOCTL_VENDOR _IOR('U', 0x20, int) - #define SCANNER_IOCTL_PRODUCT _IOR('U', 0x21, int) - #define SCANNER_IOCTL_CTRLMSG _IOWR('U', 0x22, devrequest) ! typedef struct { ! __u8 requesttype; ! __u8 request; ! __u16 value; ! __u16 index; ! __u16 length; ! } devrequest __attribute__ ((packed)); ! ! ! static void _UsbWriteControl(int fd, int iValue, int iIndex, void *pabData, int iSize) { --- 64,70 ---- #include <linux/usb.h> /* linux usb ioctls */ ! void _UsbWriteControl(int fd, int iValue, int iIndex, void *pabData, int iSize) { *************** *** 60,76 **** cmsg.data = pabData; ! DBG(DBG_MSG, "Write: reqtype = 0x%02X, req = 0x%02X, value = %04X, len = %d\n", cmsg.req.requesttype, cmsg.req.request,cmsg.req.value, iSize); if( iSize > 0 ) { int i; ! DBG(DBG_MSG, " Data: " ); for( i=0; i<iSize && i<8; i++ ) ! DBG(DBG_MSG, "%02X ", ((unsigned char*)pabData)[i]); if( iSize > 8 ) ! DBG(DBG_MSG, "..." ); ! DBG(DBG_MSG, "\n" ); } ! if (fd != -1) { ioctl(fd, SCANNER_IOCTL_CTRLMSG, &cmsg); --- 81,97 ---- cmsg.data = pabData; ! HP5400_DBG(DBG_MSG, "Write: reqtype = 0x%02X, req = 0x%02X, value = %04X, len = %d\n", cmsg.req.requesttype, cmsg.req.request,cmsg.req.value, iSize); if( iSize > 0 ) { int i; ! HP5400_DBG(DBG_MSG, " Data: " ); for( i=0; i<iSize && i<8; i++ ) ! HP5400_DBG(DBG_MSG, "%02X ", ((unsigned char*)pabData)[i]); if( iSize > 8 ) ! HP5400_DBG(DBG_MSG, "..." ); ! HP5400_DBG(DBG_MSG, "\n" ); } ! if (fd != -1) { ioctl(fd, SCANNER_IOCTL_CTRLMSG, &cmsg); *************** *** 79,87 **** void hp5400_command_write_noverify( int fd, int iValue, void *pabData, int iSize) ! { _UsbWriteControl(fd, iValue, 0, pabData, iSize); } ! static void _UsbReadControl(int fd, int iValue, int iIndex, void *pabData, int iSize) { --- 100,108 ---- void hp5400_command_write_noverify( int fd, int iValue, void *pabData, int iSize) ! { _UsbWriteControl(fd, iValue, 0, pabData, iSize); } ! void _UsbReadControl(int fd, int iValue, int iIndex, void *pabData, int iSize) { *************** *** 98,102 **** cmsg.data = pabData; ! DBG(DBG_MSG, "Read: reqtype = 0x%02X, req = 0x%02X, value = %04X\n", cmsg.req.requesttype, cmsg.req.request,cmsg.req.value); if (fd != -1) { --- 119,123 ---- cmsg.data = pabData; ! HP5400_DBG(DBG_MSG, "Read: reqtype = 0x%02X, req = 0x%02X, value = %04X\n", cmsg.req.requesttype, cmsg.req.request,cmsg.req.value); if (fd != -1) { *************** *** 129,133 **** ioctl(fd, SCANNER_IOCTL_PRODUCT, &iProduct); ! DBG(DBG_MSG, "vendor/product 0x%04X-0x%04X\n", iVendor, iProduct); return fd; --- 150,154 ---- ioctl(fd, SCANNER_IOCTL_PRODUCT, &iProduct); ! HP5400_DBG(DBG_MSG, "vendor/product 0x%04X-0x%04X\n", iVendor, iProduct); return fd; *************** *** 148,152 **** if (iHandle < 0) { ! DBG(DBG_ERR, "hp5400_command_verify: invalid handle\n"); return -1; } --- 169,173 ---- if (iHandle < 0) { ! HP5400_DBG(DBG_ERR, "hp5400_command_verify: invalid handle\n"); return -1; } *************** *** 157,161 **** if (abData[0] != (iCmd >> 8)) { ! DBG(DBG_ERR, "hp5400_command_verify failed, expected 0x%02X%02X, got 0x%02X%02X\n", (int)(iCmd >> 8), (int)(iCmd & 0xff), (int)abData[0], (int)abData[1]); --- 178,182 ---- if (abData[0] != (iCmd >> 8)) { ! HP5400_DBG(DBG_ERR, "hp5400_command_verify failed, expected 0x%02X%02X, got 0x%02X%02X\n", (int)(iCmd >> 8), (int)(iCmd & 0xff), (int)abData[0], (int)abData[1]); *************** *** 166,175 **** { _UsbReadControl(fd, 0x0300, 0, (char *)abData, 3); ! DBG(DBG_ERR, " error response is: %02X %02X %02X\n", abData[0], abData[1], abData[2]); return -1; } ! DBG(DBG_MSG, "Command %02X verified\n", abData[0] ); return 1; } --- 187,196 ---- { _UsbReadControl(fd, 0x0300, 0, (char *)abData, 3); ! HP5400_DBG(DBG_ERR, " error response is: %02X %02X %02X\n", abData[0], abData[1], abData[2]); return -1; } ! HP5400_DBG(DBG_MSG, "Command %02X verified\n", abData[0] ); return 1; } *************** *** 182,186 **** if (iHandle < 0) { ! DBG(DBG_ERR, "hp5400_command_read: invalid handle\n"); return -1; } --- 203,207 ---- if (iHandle < 0) { ! HP5400_DBG(DBG_ERR, "hp5400_command_read: invalid handle\n"); return -1; } *************** *** 207,211 **** if (iHandle < 0) { ! DBG(DBG_ERR, "hp5400_command_write: invalid handle\n"); return -1; } --- 228,232 ---- if (iHandle < 0) { ! HP5400_DBG(DBG_ERR, "hp5400_command_write: invalid handle\n"); return -1; } *************** *** 227,231 **** if (iHandle < 0) { ! DBG(DBG_ERR, "hp5400_command_read: invalid handle\n"); return -1; } --- 248,252 ---- if (iHandle < 0) { ! HP5400_DBG(DBG_ERR, "hp5400_command_read: invalid handle\n"); return -1; } *************** *** 241,245 **** _UsbWriteControl(fd, CMD_INITBULK3, 0, (unsigned char*)&buf, sizeof(buf) ); res = read( fd, buffer, block ); ! DBG(DBG_MSG,"Read bulk returned %d, %d remain\n", res, len ); if( res > 0 ) { --- 262,266 ---- _UsbWriteControl(fd, CMD_INITBULK3, 0, (unsigned char*)&buf, sizeof(buf) ); res = read( fd, buffer, block ); ! HP5400_DBG(DBG_MSG,"Read bulk returned %d, %d remain\n", res, len ); if( res > 0 ) { *************** *** 259,263 **** if (iHandle < 0) { ! DBG(DBG_ERR, "hp5400_command_write: invalid handle\n"); return -1; } --- 280,284 ---- if (iHandle < 0) { ! HP5400_DBG(DBG_ERR, "hp5400_command_write: invalid handle\n"); return -1; } *************** *** 266,270 **** _UsbWriteControl(fd, iCmd, 0, cmd, cmdlen ); res = read( fd, buffer, len ); ! DBG(DBG_MSG,"Read block returned %d when reading %d\n", res, len ); return res; } --- 287,291 ---- _UsbWriteControl(fd, iCmd, 0, cmd, cmdlen ); res = read( fd, buffer, len ); ! HP5400_DBG(DBG_MSG,"Read block returned %d when reading %d\n", res, len ); return res; } *************** *** 277,286 **** if (iHandle < 0) { ! DBG(DBG_ERR, "hp5400_command_write: invalid handle\n"); return -1; } fd = iHandle; ! DBG(DBG_MSG,"bulk_command_write(%04X,<%d bytes>,<%d bytes>)\n", iCmd, cmdlen, datalen); _UsbWriteControl(fd, iCmd, 0, cmd, cmdlen); --- 298,307 ---- if (iHandle < 0) { ! HP5400_DBG(DBG_ERR, "hp5400_command_write: invalid handle\n"); return -1; } fd = iHandle; ! HP5400_DBG(DBG_MSG,"bulk_command_write(%04X,<%d bytes>,<%d bytes>)\n", iCmd, cmdlen, datalen); _UsbWriteControl(fd, iCmd, 0, cmd, cmdlen); *************** *** 290,303 **** { int i; ! DBG(DBG_MSG, " Data: " ); for( i=0; i<datalen && i<block && i<8; i++ ) ! DBG(DBG_MSG, "%02X ", ((unsigned char*)data+offset)[i]); if( i >= 8 ) ! DBG(DBG_MSG, "..." ); ! DBG(DBG_MSG, "\n" ); } res = write( fd, data+offset, (datalen < block)?datalen:block ); ! DBG(DBG_MSG,"Write returned %d, %d remain\n", res, datalen ); datalen -= block; offset += block; --- 311,324 ---- { int i; ! HP5400_DBG(DBG_MSG, " Data: " ); for( i=0; i<datalen && i<block && i<8; i++ ) ! HP5400_DBG(DBG_MSG, "%02X ", ((unsigned char*)data+offset)[i]); if( i >= 8 ) ! HP5400_DBG(DBG_MSG, "..." ); ! HP5400_DBG(DBG_MSG, "\n" ); } res = write( fd, data+offset, (datalen < block)?datalen:block ); ! HP5400_DBG(DBG_MSG,"Write returned %d, %d remain\n", res, datalen ); datalen -= block; offset += block; Index: hp5400_xfer.h =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400_xfer.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** hp5400_xfer.h 26 Feb 2003 09:38:24 -0000 1.3 --- hp5400_xfer.h 26 May 2003 13:46:15 -0000 1.4 *************** *** 1,22 **** ! /* ! (c) 2003 Martijn van Oosterhout, kl...@sv... ! (c) 2002 Bertrik Sikken, be...@zo... ! ! Transport layer for communication with HP5400/5470 scanner. ! ! Add support for bulk transport of data - 19/02/2003 Martijn ! */ ! int hp5400_open(const char* filename); ! void hp5400_close(int iHandle); ! int hp5400_command_verify(int iHandle, int iCmd); ! int hp5400_command_read(int iHandle, int iCmd, int iLen, void *pbData); ! int hp5400_command_read_noverify(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, int iSize); ! int hp5400_bulk_read(int iHandle, int size, int block, FILE *file ); ! int hp5400_bulk_read_block(int iHandle, int iCmd, void *cmd, int cmdlen, void *buffer, int len ); ! int hp5400_bulk_command_write(int iHandle, int iCmd, void *cmd, int cmdlen, int len, int block, char *data ); ! int hp5400_isOn( int iHandle ); --- 1,73 ---- ! #ifndef _HP5400_XFER_H_ ! #define _HP5400_XFER_H_ ! /* sane - Scanner Access Now Easy. ! Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> ! Copyright (C) 2003 Thomas Soumarmon <tho...@co...> ! Originally copied from HP3300 testtools. Original notice follows: ! ! Copyright (C) 2001 Bertrik Sikken (be...@zo...) ! ! This file is part of the SANE package. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + As a special exception, the authors of SANE give permission for + additional uses of the libraries contained in this release of SANE. + + The exception is that, if you link a SANE library with other files + to produce an executable, this does not by itself cause the + resulting executable to be covered by the GNU General Public + License. Your use of that executable is in no way restricted on + account of linking the SANE library code into it. + + This exception does not, however, invalidate any other reasons why + the executable file might be covered by the GNU General Public + License. + + If you submit changes to SANE to the maintainers to be included in + a subsequent release, you agree by submitting the changes that + those changes may be distributed with this exception intact. + + If you write modifications of your own for SANE, it is your choice + whether to permit this exception to apply to your modifications. + If you do not wish that, delete this exception notice. + + Transport layer for communication with HP5400/5470 scanner. + + Add support for bulk transport of data - 19/02/2003 Martijn + */ + + #include <stdio.h> + + int hp5400_open (const char *filename); + void hp5400_close (int iHandle); + + int hp5400_command_verify (int iHandle, int iCmd); + int hp5400_command_read (int iHandle, int iCmd, int iLen, void *pbData); + int hp5400_command_read_noverify (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, + int iSize); + int hp5400_bulk_read (int iHandle, int size, int block, FILE * file); + int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen, + void *buffer, int len); + int hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen, + int len, int block, char *data); + int hp5400_isOn (int iHandle); + + #endif Index: releaseNotes.txt =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/releaseNotes.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** releaseNotes.txt 27 Feb 2003 13:03:45 -0000 1.1 --- releaseNotes.txt 26 May 2003 13:46:15 -0000 1.2 *************** *** 1,3 **** --- 1,8 ---- + release beta_20030526 + * integrated to SANE project 1.0.12 backends + * Makefile and files revised to also work as a standalone program + * fixed copyrights + release alpha 2_20030227 * scanning area is the visible one Index: sane-hp5400.c =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/sane-hp5400.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** sane-hp5400.c 6 Mar 2003 09:59:25 -0000 1.13 --- sane-hp5400.c 26 May 2003 13:46:15 -0000 1.14 *************** *** 1,24 **** ! /* ! Copyright (C) 2003 Martijn van Oosterhout <kl...@sv...> ! ! This file was initially copied from the hp3300 testools and adjusted to ! suit. Original copyright notice follows: ! ! Copyright (C) 2001 Bertrik Sikken (be...@zo...) ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License [...1363 lines suppressed...] SANE_Status ! sane_get_select_fd(SANE_Handle h, SANE_Int *fd) { ! DBG(DBG_MSG, "sane_select_fd\n"); /* prevent compiler from complaining about unused parameters */ --- 983,989 ---- SANE_Status ! sane_get_select_fd (SANE_Handle h, SANE_Int * fd) { ! HP5400_DBG (DBG_MSG, "sane_select_fd\n"); /* prevent compiler from complaining about unused parameters */ *************** *** 931,933 **** return SANE_STATUS_UNSUPPORTED; } - --- 993,994 ---- |