| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  | /*.............................................................................
 | 
					
						
							|  |  |  |  * Project : SANE library for Plustek flatbed scanners. | 
					
						
							|  |  |  |  *............................................................................. | 
					
						
							|  |  |  |  * File:	 plustek.h - definitions for the backend | 
					
						
							|  |  |  |  *............................................................................. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * based on Kazuhiro Sasayama previous | 
					
						
							|  |  |  |  * Work on plustek.[ch] file from the SANE package. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * original code taken from sane-0.71 | 
					
						
							|  |  |  |  * Copyright (C) 1997 Hypercore Software Design, Ltd. | 
					
						
							| 
									
										
										
										
											2002-03-26 08:35:59 +00:00
										 |  |  |  * Copyright (C) 2000-2002 Gerhard Jaeger <gerhard@gjaeger.de> | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  |  *............................................................................. | 
					
						
							|  |  |  |  * History: | 
					
						
							|  |  |  |  * 0.30 - initial version | 
					
						
							|  |  |  |  * 0.31 - no changes | 
					
						
							|  |  |  |  * 0.32 - no changes | 
					
						
							|  |  |  |  * 0.33 - no changes | 
					
						
							|  |  |  |  * 0.34 - moved some definitions and typedefs from plustek.c | 
					
						
							|  |  |  |  * 0.35 - removed OPT_MODEL from options list | 
					
						
							| 
									
										
										
										
											2000-11-10 10:28:12 +00:00
										 |  |  |  *		  added max_y to struct Plustek_Scan | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  |  * 0.36 - added reader_pid, pipe and bytes_read to struct Plustek_Scanner | 
					
						
							|  |  |  |  *		  removed unused variables from struct Plustek_Scanner | 
					
						
							| 
									
										
										
										
											2000-08-24 06:38:30 +00:00
										 |  |  |  *        moved fd from struct Plustek_Scanner to Plustek_Device | 
					
						
							|  |  |  |  *		  added next members to struct Plustek_Scanner and Plustek_Device | 
					
						
							| 
									
										
										
										
											2000-12-07 10:27:42 +00:00
										 |  |  |  * 0.37 - added max_x to struct Plustek_Device | 
					
						
							|  |  |  |  * 0.38 - added caps to struct Plustek_Device | 
					
						
							|  |  |  |  *        added exit code to struct Plustek_Scanner | 
					
						
							|  |  |  |  *        removed dropout stuff | 
					
						
							| 
									
										
										
										
											2001-12-29 15:34:03 +00:00
										 |  |  |  * 0.39 - PORTTYPE enum | 
					
						
							|  |  |  |  *        added function pointers to control a scanner device | 
					
						
							|  |  |  |  *        (Parport and USB) | 
					
						
							|  |  |  |  * 0.40 - added USB stuff | 
					
						
							| 
									
										
										
										
											2002-01-10 19:39:32 +00:00
										 |  |  |  * 0.41 - added configuration stuff | 
					
						
							| 
									
										
										
										
											2002-03-10 15:53:13 +00:00
										 |  |  |  * 0.42 - added custom gamma tables | 
					
						
							| 
									
										
										
										
											2002-03-16 17:57:16 +00:00
										 |  |  |  *        changed usbId to static array | 
					
						
							|  |  |  |  *		  added _MAX_ID_LEN | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  *............................................................................. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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 __PLUSTEK_H__
 | 
					
						
							|  |  |  | #define __PLUSTEK_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /************************ some definitions ***********************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define MM_PER_INCH         25.4
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PLUSTEK_CONFIG_FILE	"plustek.conf"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef PATH_MAX
 | 
					
						
							|  |  |  | # define PATH_MAX 1024
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * the default image size | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define _DEFAULT_TLX  		0		/* 0..216 mm */
 | 
					
						
							|  |  |  | #define _DEFAULT_TLY  		0		/* 0..297 mm */
 | 
					
						
							|  |  |  | #define _DEFAULT_BRX		126		/* 0..216 mm*/
 | 
					
						
							|  |  |  | #define _DEFAULT_BRY		76.21	/* 0..297 mm */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define _DEFAULT_TP_TLX  	3.5		/* 0..42.3 mm */
 | 
					
						
							|  |  |  | #define _DEFAULT_TP_TLY  	10.5	/* 0..43.1 mm */
 | 
					
						
							|  |  |  | #define _DEFAULT_TP_BRX		38.5	/* 0..42.3 mm */
 | 
					
						
							|  |  |  | #define _DEFAULT_TP_BRY		33.5	/* 0..43.1 mm */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define _DEFAULT_NEG_TLX  	1.5		/* 0..38.9 mm */
 | 
					
						
							|  |  |  | #define _DEFAULT_NEG_TLY  	1.5		/* 0..29.6 mm */
 | 
					
						
							|  |  |  | #define _DEFAULT_NEG_BRX	37.5	/* 0..38.9 mm */
 | 
					
						
							|  |  |  | #define _DEFAULT_NEG_BRY	25.5	/* 0..29.6 mm */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * image sizes for normal, transparent and negative modes | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define _NORMAL_X		216.0
 | 
					
						
							|  |  |  | #define _NORMAL_Y		297.0
 | 
					
						
							|  |  |  | #define _TP_X			((double)_TPAPageWidth/300.0 * MM_PER_INCH)
 | 
					
						
							|  |  |  | #define _TP_Y			((double)_TPAPageHeight/300.0 * MM_PER_INCH)
 | 
					
						
							|  |  |  | #define _NEG_X			((double)_NegativePageWidth/300.0 * MM_PER_INCH)
 | 
					
						
							|  |  |  | #define _NEG_Y			((double)_NegativePageHeight/300.0 * MM_PER_INCH)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-03-16 17:57:16 +00:00
										 |  |  | #define _MAX_ID_LEN	20
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  | /************************ some structures ************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum { | 
					
						
							|  |  |  |     OPT_NUM_OPTS = 0, | 
					
						
							|  |  |  |     OPT_MODE_GROUP, | 
					
						
							|  |  |  |     OPT_MODE, | 
					
						
							|  |  |  | 	OPT_EXT_MODE, | 
					
						
							|  |  |  |     OPT_RESOLUTION, | 
					
						
							|  |  |  |     OPT_GEOMETRY_GROUP, | 
					
						
							|  |  |  |     OPT_TL_X, | 
					
						
							|  |  |  |     OPT_TL_Y, | 
					
						
							|  |  |  |     OPT_BR_X, | 
					
						
							|  |  |  |     OPT_BR_Y, | 
					
						
							| 
									
										
										
										
											2002-03-10 15:53:13 +00:00
										 |  |  | 	OPT_ENHANCEMENT_GROUP, | 
					
						
							|  |  |  |     OPT_HALFTONE, | 
					
						
							|  |  |  |     OPT_BRIGHTNESS, | 
					
						
							|  |  |  |     OPT_CONTRAST, | 
					
						
							|  |  |  |     OPT_CUSTOM_GAMMA, | 
					
						
							|  |  |  |     OPT_GAMMA_VECTOR, | 
					
						
							|  |  |  |     OPT_GAMMA_VECTOR_R, | 
					
						
							|  |  |  |     OPT_GAMMA_VECTOR_G, | 
					
						
							|  |  |  |     OPT_GAMMA_VECTOR_B, | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  |     NUM_OPTIONS | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-29 15:34:03 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2002-01-10 19:39:32 +00:00
										 |  |  |  * to distinguish between parallelport and USB device | 
					
						
							| 
									
										
										
										
											2001-12-29 15:34:03 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | typedef enum { | 
					
						
							| 
									
										
										
										
											2002-01-10 19:39:32 +00:00
										 |  |  | 	PARPORT = 0, | 
					
						
							| 
									
										
										
										
											2001-12-29 15:34:03 +00:00
										 |  |  | 	USB, | 
					
						
							|  |  |  | 	NUM_PORTTYPES | 
					
						
							|  |  |  | } PORTTYPE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-24 06:38:30 +00:00
										 |  |  | typedef struct Plustek_Device | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2000-12-07 10:27:42 +00:00
										 |  |  | 	struct Plustek_Device *next;             /* pointer to next dev in list  */ | 
					
						
							|  |  |  | 	int 				   fd;				 /* device handle                */ | 
					
						
							|  |  |  |     char                  *name;             /* (to avoid compiler warnings!)*/ | 
					
						
							|  |  |  |     SANE_Device 		   sane;             /* info struct                  */ | 
					
						
							|  |  |  | 	SANE_Int			   max_x;            /* max XY-extension of the scan-*/ | 
					
						
							|  |  |  | 	SANE_Int			   max_y;            /* area                         */ | 
					
						
							|  |  |  |     SANE_Range 			   dpi_range;        /* resolution range             */ | 
					
						
							|  |  |  |     SANE_Range 			   x_range;          /* x-range of the scan-area     */ | 
					
						
							|  |  |  |     SANE_Range 			   y_range;          /* y-range of the scan-area     */ | 
					
						
							|  |  |  |     SANE_Int  		 	  *res_list;         /* to hold the available phys.  */ | 
					
						
							|  |  |  |     SANE_Int 			   res_list_size;    /* resolution values            */ | 
					
						
							|  |  |  |     ScannerCaps            caps;             /* caps reported by the driver  */ | 
					
						
							| 
									
										
										
										
											2002-03-10 15:53:13 +00:00
										 |  |  | 	AdjDef                 adj;	             /* for driver adjustment        */ | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2001-12-29 15:34:03 +00:00
										 |  |  |     /**************************** USB-stuff **********************************/ | 
					
						
							| 
									
										
										
										
											2002-03-16 17:57:16 +00:00
										 |  |  |     char                   usbId[_MAX_ID_LEN];/* to keep Vendor and product  */ | 
					
						
							| 
									
										
										
										
											2001-12-29 15:34:03 +00:00
										 |  |  |                                              /* ID string (from conf) file   */ | 
					
						
							|  |  |  | #ifdef _PLUSTEK_USB
 | 
					
						
							|  |  |  |     ScanDef                scanning;         /* here we hold all stuff for   */ | 
					
						
							|  |  |  |                                              /* the USB-scanner              */ | 
					
						
							|  |  |  | 	DeviceDef              usbDev;	 | 
					
						
							| 
									
										
										
										
											2002-04-14 13:38:04 +00:00
										 |  |  | 	struct itimerval       saveSettings;     /* for lamp timer               */ | 
					
						
							| 
									
										
										
										
											2001-12-29 15:34:03 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * each device we support may need other access functions... | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     int  (*open)       ( const char*, void* ); | 
					
						
							|  |  |  |     int  (*close)      ( struct Plustek_Device* ); | 
					
						
							|  |  |  |     void (*shutdown)   ( struct Plustek_Device* ); | 
					
						
							|  |  |  |     int  (*getCaps)    ( struct Plustek_Device* ); | 
					
						
							|  |  |  |     int  (*getLensInfo)( struct Plustek_Device*, pLensInfo  ); | 
					
						
							|  |  |  |     int  (*getCropInfo)( struct Plustek_Device*, pCropInfo  ); | 
					
						
							|  |  |  |     int  (*putImgInfo) ( struct Plustek_Device*, pImgDef    ); | 
					
						
							|  |  |  |     int  (*setScanEnv) ( struct Plustek_Device*, pScanInfo  ); | 
					
						
							| 
									
										
										
										
											2002-03-10 15:53:13 +00:00
										 |  |  |     int  (*setMap)     ( struct Plustek_Device*, SANE_Word*, | 
					
						
							|  |  |  | 												 SANE_Word, SANE_Word ); | 
					
						
							| 
									
										
										
										
											2001-12-29 15:34:03 +00:00
										 |  |  |     int  (*startScan)  ( struct Plustek_Device*, pStartScan ); | 
					
						
							|  |  |  |     int  (*stopScan)   ( struct Plustek_Device*, int* ); | 
					
						
							|  |  |  |     int  (*readImage)  ( struct Plustek_Device*, SANE_Byte*, unsigned long ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } Plustek_Device, *pPlustek_Device; | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef union | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	SANE_Word w; | 
					
						
							|  |  |  | 	SANE_Word *wa;		/* word array */ | 
					
						
							|  |  |  | 	SANE_String s; | 
					
						
							|  |  |  | } Option_Value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-24 06:38:30 +00:00
										 |  |  | typedef struct Plustek_Scanner | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2000-08-24 06:38:30 +00:00
										 |  |  |     struct Plustek_Scanner *next; | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  |     pid_t 					reader_pid;		/* process id of reader          */ | 
					
						
							| 
									
										
										
										
											2000-12-07 10:27:42 +00:00
										 |  |  |     SANE_Status             exit_code;      /* status of the reader process  */ | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  |     int 					pipe;			/* pipe to reader process        */ | 
					
						
							|  |  |  | 	unsigned long			bytes_read;		/* number of bytes currently read*/ | 
					
						
							|  |  |  |     Plustek_Device 		   *hw;				/* pointer to current device     */ | 
					
						
							|  |  |  |     Option_Value 			val[NUM_OPTIONS]; | 
					
						
							|  |  |  |     SANE_Byte 			   *buf;            /* the image buffer              */ | 
					
						
							|  |  |  |     SANE_Bool 				scanning;       /* TRUE during scan-process      */ | 
					
						
							|  |  |  |     SANE_Parameters 		params;         /* for keeping the parameter     */ | 
					
						
							| 
									
										
										
										
											2002-03-10 15:53:13 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	/************************** gamma tables *********************************/ | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	SANE_Word	gamma_table[4][4096]; | 
					
						
							|  |  |  | 	SANE_Range	gamma_range; | 
					
						
							|  |  |  | 	int 		gamma_length; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  |     SANE_Option_Descriptor	opt[NUM_OPTIONS]; | 
					
						
							| 
									
										
										
										
											2002-03-10 15:53:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } Plustek_Scanner, *pPlustek_Scanner; | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef const struct mode_param { | 
					
						
							|  |  |  | 	int color; | 
					
						
							|  |  |  | 	int depth; | 
					
						
							|  |  |  | 	int scanmode; | 
					
						
							|  |  |  | } ModeParam, *pModeParam; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-10 19:39:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * for collecting configuration info... | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	char     devName[PATH_MAX]; | 
					
						
							|  |  |  | 	PORTTYPE porttype; | 
					
						
							| 
									
										
										
										
											2002-03-16 17:57:16 +00:00
										 |  |  | 	char     usbId[_MAX_ID_LEN];	 | 
					
						
							| 
									
										
										
										
											2002-01-10 19:39:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* contains the stuff to adjust... */ | 
					
						
							|  |  |  | 	AdjDef   adj; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } CnfDef, *pCnfDef; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-12 15:11:46 +00:00
										 |  |  | #endif	/* guard __PLUSTEK_H__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* END PLUSTEK.H.............................................................*/ |