2000-08-12 15:11:46 +00:00
|
|
|
/*.............................................................................
|
|
|
|
* Project : SANE library for Plustek flatbed scanners.
|
|
|
|
*.............................................................................
|
2003-01-10 13:32:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file plustek.h
|
|
|
|
* @brief Definitions for the backend.
|
2000-08-12 15:11:46 +00:00
|
|
|
*
|
2003-01-10 13:32:11 +00:00
|
|
|
* Based on Kazuhiro Sasayama previous
|
|
|
|
* Work on plustek.[ch] file from the SANE package.<br>
|
|
|
|
*
|
|
|
|
* original code taken from sane-0.71<br>
|
|
|
|
* Copyright (C) 1997 Hypercore Software Design, Ltd.<br>
|
2004-01-09 14:24:30 +00:00
|
|
|
* Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
|
2000-08-12 15:11:46 +00:00
|
|
|
*
|
|
|
|
* History:
|
2003-01-10 13:32:11 +00:00
|
|
|
* - 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
|
|
|
|
* - added max_y to struct Plustek_Scan
|
|
|
|
* - 0.36 - added reader_pid, pipe and bytes_read to struct Plustek_Scanner
|
|
|
|
* - removed unused variables from struct Plustek_Scanner
|
|
|
|
* - moved fd from struct Plustek_Scanner to Plustek_Device
|
|
|
|
* - added next members to struct Plustek_Scanner and Plustek_Device
|
|
|
|
* - 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
|
|
|
|
* - 0.39 - PORTTYPE enum
|
|
|
|
* - added function pointers to control a scanner device
|
2001-12-29 15:34:03 +00:00
|
|
|
* (Parport and USB)
|
2003-01-10 13:32:11 +00:00
|
|
|
* - 0.40 - added USB stuff
|
|
|
|
* - 0.41 - added configuration stuff
|
|
|
|
* - 0.42 - added custom gamma tables
|
|
|
|
* - changed usbId to static array
|
|
|
|
* - added _MAX_ID_LEN
|
|
|
|
* - 0.43 - no changes
|
|
|
|
* - 0.44 - added flag initialized
|
2003-01-24 11:44:04 +00:00
|
|
|
* - 0.45 - added readLine function
|
2003-09-23 07:10:53 +00:00
|
|
|
* - 0.46 - flag initialized is now used as device index
|
|
|
|
* - added calFile to Plustek_Device
|
2003-09-29 14:59:13 +00:00
|
|
|
* - removed _OPT_HALFTONE
|
2003-12-18 13:24:26 +00:00
|
|
|
* - 0.47 - added mov to adjustment
|
|
|
|
* - changed stopScan function definition
|
|
|
|
* - removed open function
|
2003-01-10 13:32:11 +00:00
|
|
|
* .
|
|
|
|
* <hr>
|
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.
|
2003-01-10 13:32:11 +00:00
|
|
|
* <hr>
|
2000-08-12 15:11:46 +00:00
|
|
|
*/
|
|
|
|
#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
|
|
|
|
|
2003-09-29 14:59:13 +00:00
|
|
|
#define _MEASURE_BASE 300UL
|
|
|
|
#define _DEF_DPI 50
|
|
|
|
|
|
|
|
/** the default image size
|
2000-08-12 15:11:46 +00:00
|
|
|
*/
|
|
|
|
#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 */
|
|
|
|
|
2003-09-29 14:59:13 +00:00
|
|
|
/** image sizes for normal, transparent and negative modes
|
2000-08-12 15:11:46 +00:00
|
|
|
*/
|
2004-01-09 14:24:30 +00:00
|
|
|
#define _TPAPageWidth 500U
|
|
|
|
#define _TPAPageHeight 510U
|
|
|
|
#define _TPAMinDpi 150
|
|
|
|
#define _TPAModeSupportMin COLOR_TRUE24
|
2003-09-29 14:59:13 +00:00
|
|
|
|
|
|
|
#define _NegativePageWidth 460UL
|
|
|
|
#define _NegativePageHeight 350UL
|
|
|
|
|
2004-01-09 14:24:30 +00:00
|
|
|
#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)
|
2000-08-12 15:11:46 +00:00
|
|
|
|
2003-09-29 14:59:13 +00:00
|
|
|
/** scan modes
|
|
|
|
*/
|
|
|
|
#define COLOR_BW 0
|
|
|
|
#define COLOR_256GRAY 1
|
|
|
|
#define COLOR_GRAY16 2
|
|
|
|
#define COLOR_TRUE24 3
|
|
|
|
#define COLOR_TRUE48 4
|
|
|
|
|
|
|
|
/** usb id buffer
|
|
|
|
*/
|
2002-03-16 17:57:16 +00:00
|
|
|
#define _MAX_ID_LEN 20
|
|
|
|
|
2003-09-29 14:59:13 +00:00
|
|
|
/**
|
|
|
|
*/
|
2004-01-09 14:24:30 +00:00
|
|
|
#define SFLAG_ADF 0x00000010 /* Automatic document feeder */
|
|
|
|
#define SFLAG_TPA 0x00000080 /* has transparency adapter */
|
2003-09-29 14:59:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
#define SCANDEF_Transparency 0x00000100 /* Scanning from transparency*/
|
|
|
|
#define SCANDEF_Negative 0x00000200 /* Scanning from negative */
|
|
|
|
#define SCANDEF_QualityScan 0x00000400 /* Scanning in quality mode */
|
|
|
|
#define SCANDEF_ContinuousScan 0x00001000
|
|
|
|
#define SCANDEF_TPA (SCANDEF_Transparency | SCANDEF_Negative)
|
|
|
|
|
|
|
|
#define SCANDEF_Adf 0x00020000 /* Scan from ADF tray */
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
#define SOURCE_Reflection 0
|
|
|
|
#define SOURCE_Transparency 1
|
|
|
|
#define SOURCE_Negative 2
|
|
|
|
#define SOURCE_ADF 3
|
|
|
|
|
|
|
|
/** for Gamma tables
|
|
|
|
*/
|
|
|
|
#define _MAP_RED 0
|
|
|
|
#define _MAP_GREEN 1
|
|
|
|
#define _MAP_BLUE 2
|
|
|
|
#define _MAP_MASTER 3
|
|
|
|
|
|
|
|
/** generic error codes...
|
|
|
|
*/
|
|
|
|
#define _FIRST_ERR -9000
|
|
|
|
|
|
|
|
#define _E_ALLOC (_FIRST_ERR-1) /**< error allocating memory */
|
|
|
|
#define _E_INVALID (_FIRST_ERR-2) /**< invalid parameter detected */
|
|
|
|
#define _E_INTERNAL (_FIRST_ERR-3) /**< internal error */
|
|
|
|
#define _E_ABORT (_FIRST_ERR-4) /**< operation aborted */
|
|
|
|
|
|
|
|
#define _E_LAMP_NOT_IN_POS (_FIRST_ERR-10)
|
|
|
|
#define _E_LAMP_NOT_STABLE (_FIRST_ERR-11)
|
|
|
|
#define _E_NODATA (_FIRST_ERR-12)
|
|
|
|
#define _E_BUFFER_TOO_SMALL (_FIRST_ERR-13)
|
|
|
|
#define _E_DATAREAD (_FIRST_ERR-14)
|
|
|
|
|
|
|
|
|
2000-08-12 15:11:46 +00:00
|
|
|
/************************ some structures ************************************/
|
|
|
|
|
|
|
|
enum {
|
2003-09-29 14:59:13 +00:00
|
|
|
OPT_NUM_OPTS = 0,
|
|
|
|
OPT_MODE_GROUP,
|
|
|
|
OPT_MODE,
|
2000-08-12 15:11:46 +00:00
|
|
|
OPT_EXT_MODE,
|
2003-09-29 14:59:13 +00:00
|
|
|
OPT_RESOLUTION,
|
|
|
|
OPT_PREVIEW,
|
|
|
|
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,
|
2003-09-29 14:59:13 +00:00
|
|
|
OPT_BRIGHTNESS,
|
|
|
|
OPT_CONTRAST,
|
|
|
|
OPT_CUSTOM_GAMMA,
|
|
|
|
OPT_GAMMA_VECTOR,
|
|
|
|
OPT_GAMMA_VECTOR_R,
|
|
|
|
OPT_GAMMA_VECTOR_G,
|
|
|
|
OPT_GAMMA_VECTOR_B,
|
|
|
|
NUM_OPTIONS
|
2000-08-12 15:11:46 +00:00
|
|
|
};
|
|
|
|
|
2003-09-29 14:59:13 +00:00
|
|
|
/**
|
2001-12-29 15:34:03 +00:00
|
|
|
*/
|
2003-09-29 14:59:13 +00:00
|
|
|
typedef struct {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
} OffsDef, *pOffsDef;
|
2001-12-29 15:34:03 +00:00
|
|
|
|
2003-09-23 07:10:53 +00:00
|
|
|
/** for adjusting the scanner settings
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2003-12-18 13:24:26 +00:00
|
|
|
int mov; /**< model override */
|
2003-09-23 07:10:53 +00:00
|
|
|
int lampOff;
|
|
|
|
int lampOffOnEnd;
|
|
|
|
int warmup;
|
|
|
|
int enableTpa;
|
|
|
|
int skipCalibration;
|
|
|
|
int skipFine;
|
|
|
|
int skipFineWhite;
|
|
|
|
int invertNegatives;
|
|
|
|
int cacheCalData;
|
|
|
|
int altCalibrate; /* force use of the alternate canoscan
|
|
|
|
autocal; perhaps other Canon
|
|
|
|
scanners require the alternate
|
|
|
|
autocalibration as well */
|
|
|
|
int rgain;
|
|
|
|
int ggain;
|
|
|
|
int bgain;
|
|
|
|
|
|
|
|
OffsDef pos; /* for adjusting normal scan area */
|
|
|
|
OffsDef tpa; /* for adjusting transparency scan area */
|
|
|
|
OffsDef neg; /* for adjusting negative scan area */
|
|
|
|
|
|
|
|
int posShadingY;
|
|
|
|
int tpaShadingY;
|
|
|
|
int negShadingY;
|
|
|
|
|
|
|
|
/* for adjusting the default gamma settings */
|
|
|
|
double rgamma;
|
|
|
|
double ggamma;
|
|
|
|
double bgamma;
|
|
|
|
|
|
|
|
double graygamma;
|
|
|
|
|
|
|
|
} AdjDef, *pAdjDef;
|
|
|
|
|
2003-09-29 14:59:13 +00:00
|
|
|
typedef struct {
|
|
|
|
unsigned short x;
|
|
|
|
unsigned short y;
|
|
|
|
unsigned short cx;
|
|
|
|
unsigned short cy;
|
|
|
|
} CropRect, *pCropRect;
|
|
|
|
|
|
|
|
typedef struct image {
|
|
|
|
unsigned long dwFlag;
|
|
|
|
CropRect crArea;
|
|
|
|
XY xyDpi;
|
|
|
|
unsigned short wDataType;
|
|
|
|
} ImgDef, *pImgDef;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long dwPixelsPerLine;
|
|
|
|
unsigned long dwBytesPerLine;
|
|
|
|
unsigned long dwLinesPerArea;
|
|
|
|
ImgDef ImgDef;
|
|
|
|
} CropInfo, *pCropInfo;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ImgDef ImgDef;
|
|
|
|
short siBrightness;
|
|
|
|
short siContrast;
|
|
|
|
} ScanInfo, *pScanInfo;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long dwFlag;
|
|
|
|
unsigned short wMaxExtentX; /**< scanarea width */
|
|
|
|
unsigned short wMaxExtentY; /**< scanarea height */
|
|
|
|
} ScannerCaps, *pScannerCaps;
|
|
|
|
|
|
|
|
/** for defining the scanmodes
|
|
|
|
*/
|
|
|
|
typedef const struct mode_param
|
|
|
|
{
|
|
|
|
int color;
|
|
|
|
int depth;
|
|
|
|
int scanmode;
|
|
|
|
} ModeParam, *pModeParam;
|
|
|
|
|
2000-08-24 06:38:30 +00:00
|
|
|
typedef struct Plustek_Device
|
2000-08-12 15:11:46 +00:00
|
|
|
{
|
2003-09-23 07:10:53 +00:00
|
|
|
SANE_Int initialized; /* device already initialized? */
|
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!)*/
|
2003-09-23 07:10:53 +00:00
|
|
|
char *calFile; /* for saving calibration data */
|
2000-12-07 10:27:42 +00:00
|
|
|
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 */
|
2003-09-29 14:59:13 +00:00
|
|
|
struct ScanDef scanning; /* here we hold all stuff for */
|
2001-12-29 15:34:03 +00:00
|
|
|
/* the USB-scanner */
|
2003-10-02 07:44:08 +00:00
|
|
|
struct DeviceDef usbDev;
|
2003-10-17 11:14:08 +00:00
|
|
|
#ifdef HAVE_SETITIMER
|
2002-04-14 13:38:04 +00:00
|
|
|
struct itimerval saveSettings; /* for lamp timer */
|
2003-10-02 07:44:08 +00:00
|
|
|
#endif
|
2001-12-29 15:34:03 +00:00
|
|
|
/*
|
|
|
|
* each device we support may need other access functions...
|
|
|
|
*/
|
|
|
|
int (*close) ( struct Plustek_Device* );
|
|
|
|
void (*shutdown) ( struct Plustek_Device* );
|
|
|
|
int (*getCaps) ( struct Plustek_Device* );
|
|
|
|
int (*getCropInfo)( struct Plustek_Device*, pCropInfo );
|
|
|
|
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 );
|
2003-09-29 14:59:13 +00:00
|
|
|
int (*startScan) ( struct Plustek_Device* );
|
2003-12-18 13:24:26 +00:00
|
|
|
int (*stopScan) ( struct Plustek_Device* );
|
2003-01-24 11:44:04 +00:00
|
|
|
int (*prepare) ( struct Plustek_Device*, SANE_Byte* );
|
|
|
|
int (*readLine) ( struct Plustek_Device* );
|
|
|
|
|
2001-12-29 15:34:03 +00:00
|
|
|
} Plustek_Device, *pPlustek_Device;
|
2000-08-12 15:11:46 +00:00
|
|
|
|
2003-09-23 07:10:53 +00:00
|
|
|
#ifndef SANE_OPTION
|
|
|
|
/* for compatibility with older versions */
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
SANE_Word w;
|
|
|
|
SANE_Word *wa; /* word array */
|
|
|
|
SANE_String s;
|
|
|
|
} Option_Value;
|
|
|
|
#endif
|
|
|
|
|
2000-08-24 06:38:30 +00:00
|
|
|
typedef struct Plustek_Scanner
|
2000-08-12 15:11:46 +00:00
|
|
|
{
|
2003-10-05 16:00:30 +00:00
|
|
|
struct Plustek_Scanner *next;
|
|
|
|
pid_t reader_pid; /* process id of reader */
|
|
|
|
SANE_Status exit_code; /* status of the reader process */
|
2003-10-08 20:34:10 +00:00
|
|
|
int r_pipe; /* pipe to reader process */
|
|
|
|
int w_pipe; /* pipe from reader process */
|
2003-10-05 16:00:30 +00:00
|
|
|
unsigned long bytes_read; /* number of bytes currently read*/
|
|
|
|
pPlustek_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 */
|
|
|
|
|
|
|
|
/************************** gamma tables *********************************/
|
|
|
|
|
|
|
|
SANE_Word gamma_table[4][4096];
|
|
|
|
SANE_Range gamma_range;
|
|
|
|
int gamma_length;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2003-09-23 07:10:53 +00:00
|
|
|
/** for collecting configuration info...
|
2002-01-10 19:39:32 +00:00
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
char devName[PATH_MAX];
|
2003-12-18 13:24:26 +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.............................................................*/
|