1141cc406Sopenharmony_ci/******************************************************************************* 2141cc406Sopenharmony_ci * SANE - Scanner Access Now Easy. 3141cc406Sopenharmony_ci 4141cc406Sopenharmony_ci microtek2.h 5141cc406Sopenharmony_ci 6141cc406Sopenharmony_ci This file (C) 1998, 1999 Bernd Schroeder 7141cc406Sopenharmony_ci 2000, 2001 Karsten Festag 8141cc406Sopenharmony_ci 9141cc406Sopenharmony_ci This file is part of the SANE package. 10141cc406Sopenharmony_ci 11141cc406Sopenharmony_ci This program is free software; you can redistribute it and/or 12141cc406Sopenharmony_ci modify it under the terms of the GNU General Public License as 13141cc406Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 14141cc406Sopenharmony_ci License, or (at your option) any later version. 15141cc406Sopenharmony_ci 16141cc406Sopenharmony_ci This program is distributed in the hope that it will be useful, but 17141cc406Sopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 18141cc406Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19141cc406Sopenharmony_ci General Public License for more details. 20141cc406Sopenharmony_ci 21141cc406Sopenharmony_ci You should have received a copy of the GNU General Public License 22141cc406Sopenharmony_ci along with this program. If not, see <https://www.gnu.org/licenses/>. 23141cc406Sopenharmony_ci 24141cc406Sopenharmony_ci As a special exception, the authors of SANE give permission for 25141cc406Sopenharmony_ci additional uses of the libraries contained in this release of SANE. 26141cc406Sopenharmony_ci 27141cc406Sopenharmony_ci The exception is that, if you link a SANE library with other files 28141cc406Sopenharmony_ci to produce an executable, this does not by itself cause the 29141cc406Sopenharmony_ci resulting executable to be covered by the GNU General Public 30141cc406Sopenharmony_ci License. Your use of that executable is in no way restricted on 31141cc406Sopenharmony_ci account of linking the SANE library code into it. 32141cc406Sopenharmony_ci 33141cc406Sopenharmony_ci This exception does not, however, invalidate any other reasons why 34141cc406Sopenharmony_ci the executable file might be covered by the GNU General Public 35141cc406Sopenharmony_ci License. 36141cc406Sopenharmony_ci 37141cc406Sopenharmony_ci If you submit changes to SANE to the maintainers to be included in 38141cc406Sopenharmony_ci a subsequent release, you agree by submitting the changes that 39141cc406Sopenharmony_ci those changes may be distributed with this exception intact. 40141cc406Sopenharmony_ci 41141cc406Sopenharmony_ci If you write modifications of your own for SANE, it is your choice 42141cc406Sopenharmony_ci whether to permit this exception to apply to your modifications. 43141cc406Sopenharmony_ci If you do not wish that, delete this exception notice. 44141cc406Sopenharmony_ci 45141cc406Sopenharmony_ci 46141cc406Sopenharmony_ci*******************************************************************************/ 47141cc406Sopenharmony_ci 48141cc406Sopenharmony_ci 49141cc406Sopenharmony_ci#ifndef microtek2_h 50141cc406Sopenharmony_ci#define microtek2_h 51141cc406Sopenharmony_ci 52141cc406Sopenharmony_ci#include <sys/types.h> 53141cc406Sopenharmony_ci 54141cc406Sopenharmony_ci 55141cc406Sopenharmony_ci/******************************************************************************/ 56141cc406Sopenharmony_ci/* Miscellaneous defines */ 57141cc406Sopenharmony_ci/******************************************************************************/ 58141cc406Sopenharmony_ci 59141cc406Sopenharmony_ci#ifndef PATH_MAX 60141cc406Sopenharmony_ci# define PATH_MAX 1024 61141cc406Sopenharmony_ci#endif 62141cc406Sopenharmony_ci 63141cc406Sopenharmony_ci#ifdef HAVE_AUTHORIZATION 64141cc406Sopenharmony_ci#ifndef PATH_SEP 65141cc406Sopenharmony_ci#if defined(_WIN32) || defined(HAVE_OS2_H) 66141cc406Sopenharmony_ci# define PATH_SEP "\\" 67141cc406Sopenharmony_ci#else 68141cc406Sopenharmony_ci# define PATH_SEP "/" 69141cc406Sopenharmony_ci#endif 70141cc406Sopenharmony_ci#endif 71141cc406Sopenharmony_ci 72141cc406Sopenharmony_ci#define MAX_LINE_LEN 512 /* max length of entry in password file */ 73141cc406Sopenharmony_ci#define PASSWD_FILE STRINGIFY(PATH_SANE_CONFIG_DIR) PATH_SEP "auth" 74141cc406Sopenharmony_ci#define SEPARATOR ':' /* separator in that file */ 75141cc406Sopenharmony_ci#define SALT "ab" /* used by crypt() */ 76141cc406Sopenharmony_ci 77141cc406Sopenharmony_ci#endif /* HAVE_AUTHORIZATION */ 78141cc406Sopenharmony_ci 79141cc406Sopenharmony_ci 80141cc406Sopenharmony_ci#define ENDIAN_TYPE(d) { unsigned i, test = 0; \ 81141cc406Sopenharmony_ci for (i=0; i < sizeof(int); i++ ) \ 82141cc406Sopenharmony_ci test += i << (8 * i); \ 83141cc406Sopenharmony_ci d = ((char *) &test)[0] == 0 ? 0 : 1; } 84141cc406Sopenharmony_ci 85141cc406Sopenharmony_ci#define MIN(a,b) ((a) < (b)) ? (a) : (b) 86141cc406Sopenharmony_ci#define MAX(a,b) ((a) > (b)) ? (a) : (b) 87141cc406Sopenharmony_ci 88141cc406Sopenharmony_ci#define MICROTEK2_MAJOR 0 89141cc406Sopenharmony_ci#define MICROTEK2_MINOR 96 90141cc406Sopenharmony_ci#define MICROTEK2_BUILD "200410042220" 91141cc406Sopenharmony_ci#define MICROTEK2_CONFIG_FILE "microtek2.conf" 92141cc406Sopenharmony_ci 93141cc406Sopenharmony_ci 94141cc406Sopenharmony_ci/******************************************************************************/ 95141cc406Sopenharmony_ci/* defines that are common to all devices */ 96141cc406Sopenharmony_ci/******************************************************************************/ 97141cc406Sopenharmony_ci 98141cc406Sopenharmony_ci#define MD_RESOLUTION_DEFAULT 72 << SANE_FIXED_SCALE_SHIFT 99141cc406Sopenharmony_ci#define MD_BRIGHTNESS_DEFAULT 100 << SANE_FIXED_SCALE_SHIFT 100141cc406Sopenharmony_ci#define MD_CONTRAST_DEFAULT 100 << SANE_FIXED_SCALE_SHIFT 101141cc406Sopenharmony_ci#define MD_THRESHOLD_DEFAULT 128 102141cc406Sopenharmony_ci#define MD_GAMMA_DEFAULT SANE_FIX(2.2) 103141cc406Sopenharmony_ci#define MD_SHADOW_DEFAULT 0 104141cc406Sopenharmony_ci#define MD_MIDTONE_DEFAULT 128 105141cc406Sopenharmony_ci#define MD_HIGHLIGHT_DEFAULT 255 106141cc406Sopenharmony_ci#define MD_EXPOSURE_DEFAULT 0 107141cc406Sopenharmony_ci#define M_BRIGHTNESS_DEFAULT 128 108141cc406Sopenharmony_ci#define M_CONTRAST_DEFAULT 128 109141cc406Sopenharmony_ci#define M_SHADOW_DEFAULT 0 110141cc406Sopenharmony_ci#define M_MIDTONE_DEFAULT 128 111141cc406Sopenharmony_ci#define M_HIGHLIGHT_DEFAULT 255 112141cc406Sopenharmony_ci#define M_EXPOSURE_DEFAULT 0 113141cc406Sopenharmony_ci#define M_THRESHOLD_DEFAULT 128 114141cc406Sopenharmony_ci 115141cc406Sopenharmony_ci 116141cc406Sopenharmony_ci/******************************************************************************/ 117141cc406Sopenharmony_ci/* SCSI commands used by the scanner */ 118141cc406Sopenharmony_ci/******************************************************************************/ 119141cc406Sopenharmony_ci 120141cc406Sopenharmony_ci/* INQUIRY */ 121141cc406Sopenharmony_ci#define INQ_CMD(d) d[0] = 0x12; d[1] = 0x00; d[2] = 0x00; \ 122141cc406Sopenharmony_ci d[3] = 0x00; d[4] = 0x00; d[5] = 0x00 123141cc406Sopenharmony_ci#define INQ_CMD_L 6 124141cc406Sopenharmony_ci#define INQ_ALLOC_L 5 /* first get 5 bytes */ 125141cc406Sopenharmony_ci#define INQ_ALLOC_P 4 126141cc406Sopenharmony_ci#define INQ_SET_ALLOC(d,s) (d)[4] = (s) 127141cc406Sopenharmony_ci 128141cc406Sopenharmony_ci#define INQ_GET_INQLEN(d,s) d = (s)[4] 129141cc406Sopenharmony_ci#define INQ_GET_QUAL(d,s) d = ((s)[0] >> 5) & 0x07 130141cc406Sopenharmony_ci#define INQ_GET_DEVT(d,s) d = (s)[0] & 0x1f 131141cc406Sopenharmony_ci#define INQ_GET_VERSION(d,s) d = (s)[2] & 0x02 132141cc406Sopenharmony_ci#define INQ_VENDOR_L 8 133141cc406Sopenharmony_ci#define INQ_GET_VENDOR(d,s) strncpy(d, &(s)[8], INQ_VENDOR_L); \ 134141cc406Sopenharmony_ci d[INQ_VENDOR_L] = '\0' 135141cc406Sopenharmony_ci#define INQ_MODEL_L 16 136141cc406Sopenharmony_ci#define INQ_GET_MODEL(d,s) strncpy(d, &(s)[16], INQ_MODEL_L); \ 137141cc406Sopenharmony_ci d[INQ_MODEL_L] = '\0' 138141cc406Sopenharmony_ci#define INQ_REV_L 4 139141cc406Sopenharmony_ci#define INQ_GET_REV(d,s) strncpy(d, &(s)[32], INQ_REV_L); \ 140141cc406Sopenharmony_ci d[INQ_REV_L] = '\0' 141141cc406Sopenharmony_ci#define INQ_GET_MODELCODE(d,s) d = (s)[36] 142141cc406Sopenharmony_ci 143141cc406Sopenharmony_ci 144141cc406Sopenharmony_ci 145141cc406Sopenharmony_ci/* TEST_UNIT_READY */ 146141cc406Sopenharmony_ci#define TUR_CMD(d) d[0]=0x00; d[1]=0x00; d[2]=0x00; \ 147141cc406Sopenharmony_ci d[3]=0x00; d[4]=0x00; d[5]=0x00 148141cc406Sopenharmony_ci#define TUR_CMD_L 6 149141cc406Sopenharmony_ci 150141cc406Sopenharmony_ci 151141cc406Sopenharmony_ci/* READ GAMMA TABLE */ 152141cc406Sopenharmony_ci#define RG_CMD(d) (d)[0] = 0x28; (d)[1] = 0x00; (d)[2] = 0x03; \ 153141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 154141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x00; \ 155141cc406Sopenharmony_ci (d)[9] = 0x00 156141cc406Sopenharmony_ci#define RG_CMD_L 10 157141cc406Sopenharmony_ci#define RG_PCORMAC(d,p) (d)[5] |= (((p) << 7) & 0x80) 158141cc406Sopenharmony_ci#define RG_COLOR(d,p) (d)[5] |= (((p) << 5) & 0x60) 159141cc406Sopenharmony_ci#define RG_WORD(d,p) (d)[5] |= ((p) & 0x01) 160141cc406Sopenharmony_ci#define RG_TRANSFERLENGTH(d,p) (d)[7] = (((p) >> 8) & 0xff); \ 161141cc406Sopenharmony_ci (d)[8] = ((p) & 0xff) 162141cc406Sopenharmony_ci 163141cc406Sopenharmony_ci/* SEND GAMMA TABLE */ 164141cc406Sopenharmony_ci#define SG_SET_CMD(d) (d)[0] = 0x2a; (d)[1] = 0x00; (d)[2] = 0x03; \ 165141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 166141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x00; \ 167141cc406Sopenharmony_ci (d)[9] = 0x00 168141cc406Sopenharmony_ci#define SG_CMD_L 10 169141cc406Sopenharmony_ci#define SG_SET_PCORMAC(d,p) (d)[5] |= (((p) << 7) & 0x80) 170141cc406Sopenharmony_ci#define SG_SET_COLOR(d,p) (d)[5] |= (((p) << 5) & 0x60) 171141cc406Sopenharmony_ci#define SG_SET_WORD(d,p) (d)[5] |= ((p) & 0x01) 172141cc406Sopenharmony_ci#define SG_SET_TRANSFERLENGTH(d,p) (d)[7] = (((p) >> 8) & 0xff); \ 173141cc406Sopenharmony_ci (d)[8] = ((p) & 0xff) 174141cc406Sopenharmony_ci#define SG_DATA_P SG_CMD_L 175141cc406Sopenharmony_ci 176141cc406Sopenharmony_ci 177141cc406Sopenharmony_ci/* READ CONTROL BITS */ 178141cc406Sopenharmony_ci#define RCB_SET_CMD(d) (d)[0] = 0x28; (d)[1] = 0x00; (d)[2] = 0x90; \ 179141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 180141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x00; \ 181141cc406Sopenharmony_ci (d)[9] = 0x00 182141cc406Sopenharmony_ci#define RCB_CMD_L 10 183141cc406Sopenharmony_ci#define RCB_SET_LENGTH(d,s) (d)[6] = (((s) >> 16) & 0xff); \ 184141cc406Sopenharmony_ci (d)[7] = (((s) >> 8) & 0xff); \ 185141cc406Sopenharmony_ci (d)[8] = ((s) & 0xff); 186141cc406Sopenharmony_ci 187141cc406Sopenharmony_ci 188141cc406Sopenharmony_ci/* READ_SCANNER_ATTRIBUTES */ 189141cc406Sopenharmony_ci#define RSA_CMD(d) d[0]=0x28; d[1]=0x00; d[2]=0x82; d[3]=0x00; \ 190141cc406Sopenharmony_ci d[4]=0x00; d[5]=0x00; d[6]=0x00; d[7]=0x00; \ 191141cc406Sopenharmony_ci d[8]=0x28; d[9]=0x00 192141cc406Sopenharmony_ci#define RSA_CMD_L 10 193141cc406Sopenharmony_ci#define RSA_SETMEDIA(d,p) d[5] |= ((p) & 0x77) 194141cc406Sopenharmony_ci#define RSA_TRANSFERLENGTH 40 195141cc406Sopenharmony_ci 196141cc406Sopenharmony_ci#define RSA_COLOR(d,s) d = (((s)[0] >> 7) & 0x01) 197141cc406Sopenharmony_ci#define RSA_ONEPASS(d,s) d = (((s)[0] >> 6) & 0x01) 198141cc406Sopenharmony_ci#define RSA_SCANNERTYPE(d,s) d = (((s)[0] >> 4) & 0x03) 199141cc406Sopenharmony_ci#define RSA_FEPROM(d,s) d = (((s)[0] >> 3) & 0x01) 200141cc406Sopenharmony_ci#define RSA_DATAFORMAT(d,s) d = ((s)[0] & 0x07) 201141cc406Sopenharmony_ci#define RSA_COLORSEQUENCE_L 3 202141cc406Sopenharmony_ci#define RSA_COLORSEQUENCE(d,s) { \ 203141cc406Sopenharmony_ci d[0] = (((s)[1] >> 6) & 0x03); \ 204141cc406Sopenharmony_ci d[1] = (((s)[1] >> 4) & 0x03); \ 205141cc406Sopenharmony_ci d[2] = (((s)[1] >> 2) & 0x03); \ 206141cc406Sopenharmony_ci } 207141cc406Sopenharmony_ci#define RSA_NIS(d,s) d = ((s)[1] & 0x02) 208141cc406Sopenharmony_ci#define RSA_DATSEQ(d,s) d = ((s)[1] & 0x01) 209141cc406Sopenharmony_ci#define RSA_CCDGAP(d,s) d = (s)[2] 210141cc406Sopenharmony_ci#define RSA_MAX_XRESOLUTION(d,s) d = ((s)[3] << 8) + (s)[4] 211141cc406Sopenharmony_ci#define RSA_MAX_YRESOLUTION(d,s) d = ((s)[5] << 8) + (s)[6] 212141cc406Sopenharmony_ci#define RSA_GEOWIDTH(d,s) d = ((s)[7] << 8) + (s)[8] 213141cc406Sopenharmony_ci#define RSA_GEOHEIGHT(d,s) d = ((s)[9] << 8) + (s)[10] 214141cc406Sopenharmony_ci#define RSA_OPTRESOLUTION(d,s) d = ((s)[11] << 8) + (s)[12] 215141cc406Sopenharmony_ci#define RSA_DEPTH(d,s) d = (((s)[13] >> 4) & 0x0f) 216141cc406Sopenharmony_ci#define RSA_SCANMODE(d,s) d = (s)[13] & 0x0f 217141cc406Sopenharmony_ci#define RSA_CCDPIXELS(d,s) d = ((s)[14] << 8) + (s)[15] 218141cc406Sopenharmony_ci#define RSA_LUTCAP(d,s) d = (s)[16] 219141cc406Sopenharmony_ci#define RSA_DNLDPTRN(d,s) d = (((s)[17] >> 7) & 0x01) 220141cc406Sopenharmony_ci#define RSA_GRAINSLCT(d,s) d = (s)[17] & 0x7f 221141cc406Sopenharmony_ci#define RSA_SUPPOPT(d,s) d = (s)[18] & 0xf3 222141cc406Sopenharmony_ci#define RSA_CALIBWHITE(d,s) d = ((s)[19] << 24) + ((s)[20] << 16) \ 223141cc406Sopenharmony_ci + ((s)[21] << 8) + (s)[22] 224141cc406Sopenharmony_ci#define RSA_CALIBSPACE(d,s) d = ((s)[23] << 24) + ((s)[24] << 16) \ 225141cc406Sopenharmony_ci + ((s)[25] << 8) + (s)[26] 226141cc406Sopenharmony_ci#define RSA_NLENS(d,s) d = (s)[27] 227141cc406Sopenharmony_ci#define RSA_NWINDOWS(d,s) d = (s)[28] 228141cc406Sopenharmony_ci#define RSA_SHTRNSFEREQU(d,s) d = (((s)[29] >> 2) & 0x3f) 229141cc406Sopenharmony_ci#define RSA_SCNBTTN(d,s) d = (((s)[29] >> 1) & 0x01) 230141cc406Sopenharmony_ci#define RSA_BUFTYPE(d,s) d = (s)[29] & 0x01 231141cc406Sopenharmony_ci#define RSA_REDBALANCE(d,s) d = ((s)[30] << 8) | (s)[31] 232141cc406Sopenharmony_ci#define RSA_GREENBALANCE(d,s) d = ((s)[32] << 8) | (s)[33] 233141cc406Sopenharmony_ci#define RSA_BLUEBALANCE(d,s) d = ((s)[34] << 8) | (s)[35] 234141cc406Sopenharmony_ci#define RSA_APSMAXFRAMES(d,s) d = (s)[36] 235141cc406Sopenharmony_ci 236141cc406Sopenharmony_ci 237141cc406Sopenharmony_ci/* READ IMAGE INFORMATION */ 238141cc406Sopenharmony_ci#define RII_SET_CMD(d) (d)[0] = 0x28; (d)[1] = 0x00; (d)[2] = 0x80; \ 239141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 240141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x10; \ 241141cc406Sopenharmony_ci (d)[9] = 0x00 242141cc406Sopenharmony_ci#define RII_CMD_L 10 243141cc406Sopenharmony_ci#define RII_RESULT_L 16 244141cc406Sopenharmony_ci 245141cc406Sopenharmony_ci#define RII_GET_WIDTHPIXEL(d,s) d = ((s)[0] << 24) + ((s)[1] << 16) \ 246141cc406Sopenharmony_ci + ((s)[2] << 8) + (s)[3] 247141cc406Sopenharmony_ci#define RII_GET_WIDTHBYTES(d,s) d = ((s)[4] << 24) + ((s)[5] << 16) \ 248141cc406Sopenharmony_ci + ((s)[6] << 8) + (s)[7] 249141cc406Sopenharmony_ci#define RII_GET_HEIGHTLINES(d,s) d = ((s)[8] << 24) + ((s)[9] << 16) \ 250141cc406Sopenharmony_ci + ((s)[10] << 8) + (s)[11] 251141cc406Sopenharmony_ci#define RII_GET_REMAINBYTES(d,s) d = ((s)[12] << 24) + ((s)[13] << 16) \ 252141cc406Sopenharmony_ci + ((s)[14] << 8) + (s)[15] 253141cc406Sopenharmony_ci 254141cc406Sopenharmony_ci/* The V300 returns some values in only two bytes */ 255141cc406Sopenharmony_ci#define RII_GET_V300_WIDTHPIXEL(d,s) d = ((s)[0] << 8) + (s)[1] 256141cc406Sopenharmony_ci#define RII_GET_V300_WIDTHBYTES(d,s) d = ((s)[2] << 8) + (s)[3] 257141cc406Sopenharmony_ci#define RII_GET_V300_HEIGHTLINES(d,s) d = ((s)[4] << 8) + (s)[5] 258141cc406Sopenharmony_ci#define RII_GET_V300_REMAINBYTES(d,s) d = ((s)[6] << 24) + ((s)[7] << 16) \ 259141cc406Sopenharmony_ci + ((s)[8] << 8) + (s)[9] 260141cc406Sopenharmony_ci 261141cc406Sopenharmony_ci/* READ SHADING INFORMATION */ 262141cc406Sopenharmony_ci#define RSI_SET_CMD(d) (d)[0] = 0x28; (d)[1] = 0x00; (d)[2] = 0x01; \ 263141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 264141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x10; \ 265141cc406Sopenharmony_ci (d)[9] = 0x00 266141cc406Sopenharmony_ci#define RSI_CMD_L 10 267141cc406Sopenharmony_ci#define RSI_SET_PCORMAC(d,s) (d)[5] |= (((s) << 7) & 0x80) 268141cc406Sopenharmony_ci#define RSI_SET_COLOR(d,s) (d)[5] |= (((s) << 5) & 0x60) 269141cc406Sopenharmony_ci#define RSI_SET_DARK(d,s) (d)[5] |= (((s) << 1) & 0x02) /*(KF)*/ 270141cc406Sopenharmony_ci /* RSI_SET_DARK was missing*/ 271141cc406Sopenharmony_ci#define RSI_SET_WORD(d,s) (d)[5] |= ((s) & 0x01) 272141cc406Sopenharmony_ci#define RSI_SET_TRANSFERLENGTH(d,s) (d)[6] = (((s) >> 16) & 0xff); \ 273141cc406Sopenharmony_ci (d)[7] = (((s) >> 8) & 0xff); \ 274141cc406Sopenharmony_ci (d)[8] = ((s) & 0xff); 275141cc406Sopenharmony_ci 276141cc406Sopenharmony_ci/* SEND SHADING INFORMATION */ 277141cc406Sopenharmony_ci#define SSI_SET_CMD(d) (d)[0] = 0x2a; (d)[1] = 0x00; (d)[2] = 0x01; \ 278141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 279141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x00; \ 280141cc406Sopenharmony_ci (d)[9] = 0x00 281141cc406Sopenharmony_ci#define SSI_CMD_L 10 282141cc406Sopenharmony_ci#define SSI_SET_PCORMAC(d,s) (d)[5] |= (((s) << 7) & 0x80) 283141cc406Sopenharmony_ci#define SSI_SET_COLOR(d,s) (d)[5] |= (((s) << 5) & 0x60) 284141cc406Sopenharmony_ci#define SSI_SET_DARK(d,s) (d)[5] |= (((s) << 1) & 0x02) 285141cc406Sopenharmony_ci#define SSI_SET_WORD(d,s) (d)[5] |= ((s) & 0x01) 286141cc406Sopenharmony_ci#define SSI_SET_TRANSFERLENGTH(d,s) (d)[6] = (((s) >> 16) & 0xff); \ 287141cc406Sopenharmony_ci (d)[7] = (((s) >> 8) & 0xff); \ 288141cc406Sopenharmony_ci (d)[8] = ((s) & 0xff); 289141cc406Sopenharmony_ci 290141cc406Sopenharmony_ci 291141cc406Sopenharmony_ci/* READ IMAGE */ 292141cc406Sopenharmony_ci 293141cc406Sopenharmony_ci/* READ IMAGE */ 294141cc406Sopenharmony_ci#define RI_SET_CMD(d) (d)[0] = 0x28; (d)[1] = 0x00; (d)[2] = 0x00; \ 295141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 296141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x00; \ 297141cc406Sopenharmony_ci (d)[9] = 0x00 298141cc406Sopenharmony_ci#define RI_CMD_L 10 299141cc406Sopenharmony_ci 300141cc406Sopenharmony_ci 301141cc406Sopenharmony_ci#define RI_SET_PCORMAC(d,s) (d)[4] |= (((s) << 7) & 0x80) 302141cc406Sopenharmony_ci#define RI_SET_COLOR(d,s) (d)[4] |= (((s) << 5) & 0x60) 303141cc406Sopenharmony_ci#define RI_SET_TRANSFERLENGTH(d,s) (d)[6] = (((s) >> 16) & 0xff); \ 304141cc406Sopenharmony_ci (d)[7] = (((s) >> 8) & 0xff); \ 305141cc406Sopenharmony_ci (d)[8] = ((s) & 0xff); 306141cc406Sopenharmony_ci 307141cc406Sopenharmony_ci 308141cc406Sopenharmony_ci/* READ SYSTEM_STATUS */ 309141cc406Sopenharmony_ci#define RSS_CMD(d) (d)[0] = 0x28; (d)[1] = 0x00; (d)[2] = 0x81; \ 310141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 311141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x09; \ 312141cc406Sopenharmony_ci (d)[9] = 0x00 313141cc406Sopenharmony_ci#define RSS_CMD_L 10 314141cc406Sopenharmony_ci#define RSS_RESULT_L 9 315141cc406Sopenharmony_ci 316141cc406Sopenharmony_ci#define RSS_FIRSTSCAN(s) (s)[0] & 0x80 317141cc406Sopenharmony_ci#define RSS_AFOCUS(s) (s)[0] & 0x40 318141cc406Sopenharmony_ci#define RSS_SSKIP(s) (s)[0] & 0x20 319141cc406Sopenharmony_ci#define RSS_STICK(s) (s)[0] & 0x10 320141cc406Sopenharmony_ci#define RSS_NTRACK(s) (s)[0] & 0x08 321141cc406Sopenharmony_ci#define RSS_NCALIB(s) (s)[0] & 0x04 322141cc406Sopenharmony_ci#define RSS_TLAMP(s) (s)[0] & 0x02 323141cc406Sopenharmony_ci#define RSS_FLAMP(s) (s)[0] & 0x01 324141cc406Sopenharmony_ci#define RSS_FSH(s) (s)[1] & 0x20 325141cc406Sopenharmony_ci#define RSS_TEFLAG(s) (s)[1] & 0x10 326141cc406Sopenharmony_ci#define RSS_WHITESTRIE(s) (s)[1] & 0x08 327141cc406Sopenharmony_ci#define RSS_RDYMAN(s) (s)[1] & 0x04 328141cc406Sopenharmony_ci#define RSS_TRDY(s) (s)[1] & 0x02 329141cc406Sopenharmony_ci#define RSS_FRDY(s) (s)[1] & 0x01 330141cc406Sopenharmony_ci#define RSS_ADP(s) (s)[2] & 0x80 331141cc406Sopenharmony_ci#define RSS_DETECT(s) (s)[2] & 0x40 332141cc406Sopenharmony_ci#define RSS_ADPTIME(s) (s)[2] & 0x3f 333141cc406Sopenharmony_ci#define RSS_LENSSTATUS(s) (s)[3] 334141cc406Sopenharmony_ci#define RSS_ALOFF(s) (s)[4] & 0x80 335141cc406Sopenharmony_ci#define RSS_TIMEREMAIN(s) (s)[4] & 0x7f 336141cc406Sopenharmony_ci#define RSS_MTMACNT(s) (s)[5] & 0x40 337141cc406Sopenharmony_ci#define RSS_MOVE(s) (s)[5] & 0x20 338141cc406Sopenharmony_ci#define RSS_LAMP(s) (s)[5] & 0x10 339141cc406Sopenharmony_ci#define RSS_EJECT(s) (s)[5] & 0x08 340141cc406Sopenharmony_ci#define RSS_TMACNT(s) (s)[5] & 0x04 341141cc406Sopenharmony_ci#define RSS_PAPER(s) (s)[5] & 0x02 342141cc406Sopenharmony_ci#define RSS_ADFCNT(s) (s)[5] & 0x01 343141cc406Sopenharmony_ci#define RSS_CANCELBTN(s) (s)[6] & 0x80 344141cc406Sopenharmony_ci#define RSS_COPYBTN(s) (s)[6] & 0x40 345141cc406Sopenharmony_ci#define RSS_EMAILBTN(s) (s)[6] & 0x20 346141cc406Sopenharmony_ci#define RSS_GOBTN(s) (s)[6] & 0x10 347141cc406Sopenharmony_ci#define RSS_TURBOBTN(s) (s)[6] & 0x08 348141cc406Sopenharmony_ci#define RSS_CURRENTMODE(s) (s)[6] & 0x07 349141cc406Sopenharmony_ci#define RSS_BUTTONCOUNT(s) (s)[7] 350141cc406Sopenharmony_ci#define RSS_MFOCUS(s) (s)[9] 351141cc406Sopenharmony_ci 352141cc406Sopenharmony_ci/* SEND SYSTEM STATUS */ 353141cc406Sopenharmony_ci#define SSS_CMD(d) (d)[0] = 0x2a; (d)[1] = 0x00; (d)[2] = 0x81; \ 354141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 355141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x09; \ 356141cc406Sopenharmony_ci (d)[9] = 0x00 357141cc406Sopenharmony_ci#define SSS_CMD_L 10 358141cc406Sopenharmony_ci#define SSS_DATA_L 9 359141cc406Sopenharmony_ci 360141cc406Sopenharmony_ci#define SSS_AFOCUS(d,p) d[0] |= (p) & 0x40 361141cc406Sopenharmony_ci#define SSS_STICK(d,p) d[0] |= (p) & 0x10 362141cc406Sopenharmony_ci#define SSS_NTRACK(d,p) d[0] |= (p) & 0x08 363141cc406Sopenharmony_ci#define SSS_NCALIB(d,p) d[0] |= (p) & 0x04 364141cc406Sopenharmony_ci#define SSS_TLAMP(d,p) d[0] |= (p) & 0x02 365141cc406Sopenharmony_ci#define SSS_FLAMP(d,p) d[0] |= (p) & 0x01 366141cc406Sopenharmony_ci#define SSS_RESERVED17(d,p) d[1] |= (p) & 0x80 367141cc406Sopenharmony_ci#define SSS_FSH(d,p) d[1] |= (p) & 0x40 368141cc406Sopenharmony_ci#define SSS_RDYMAN(d,p) d[1] |= (p) & 0x04 369141cc406Sopenharmony_ci#define SSS_TRDY(d,p) d[1] |= (p) & 0x02 370141cc406Sopenharmony_ci#define SSS_FRDY(d,p) d[1] |= (p) & 0x01 371141cc406Sopenharmony_ci#define SSS_ADP(d,p) d[2] |= (p) & 0x80 372141cc406Sopenharmony_ci#define SSS_DETECT(d,p) d[2] |= (p) & 0x40 373141cc406Sopenharmony_ci#define SSS_ADPTIME(d,p) d[2] |= (p) & 0x3f 374141cc406Sopenharmony_ci#define SSS_LENSSTATUS(d,p) d[3] |= (p) 375141cc406Sopenharmony_ci#define SSS_ALOFF(d,p) d[4] |= (p) & 0x80 376141cc406Sopenharmony_ci#define SSS_TIMEREMAIN(d,p) d[4] |= (p) & 0x7f 377141cc406Sopenharmony_ci#define SSS_TMACNT(d,p) d[5] |= (p) & 0x04 378141cc406Sopenharmony_ci#define SSS_PAPER(d,p) d[5] |= (p) & 0x02 379141cc406Sopenharmony_ci#define SSS_ADFCNT(d,p) d[5] |= (p) & 0x01 380141cc406Sopenharmony_ci#define SSS_CURRENTMODE(d,p) d[6] |= (p) & 0x07 381141cc406Sopenharmony_ci#define SSS_BUTTONCOUNT(d,p) d[6] |= (p) 382141cc406Sopenharmony_ci#define SSS_MFOCUS(s) d[9] |= (p) 383141cc406Sopenharmony_ci 384141cc406Sopenharmony_ci 385141cc406Sopenharmony_ci/* SET WINDOW */ 386141cc406Sopenharmony_ci#define SW_CMD(d) d[0]=0x24; d[1]=0x00; d[2]=0x00; d[3]=0x00; \ 387141cc406Sopenharmony_ci d[4]=0x00; d[5]=0x00; d[6]=0x00; d[7]=0x00;\ 388141cc406Sopenharmony_ci d[8]=0x00; d[9]=0x00 389141cc406Sopenharmony_ci 390141cc406Sopenharmony_ci#define SW_CMD_L 10 391141cc406Sopenharmony_ci#define SW_HEADER_L 8 392141cc406Sopenharmony_ci#define SW_BODY_L 61 393141cc406Sopenharmony_ci#define SW_CMD_P 0 /* command at position 0 */ 394141cc406Sopenharmony_ci#define SW_HEADER_P SW_CMD_L 395141cc406Sopenharmony_ci#define SW_BODY_P(n) SW_CMD_L + SW_HEADER_L + (n) * SW_BODY_L 396141cc406Sopenharmony_ci 397141cc406Sopenharmony_ci/* d: SW_CMD_P, SW_HEADER_P, SW_BODY_P(n) */ 398141cc406Sopenharmony_ci#define SW_PARAM_LENGTH(d,p) (d)[6] = ((p) >> 16) & 0xff; \ 399141cc406Sopenharmony_ci (d)[7] = ((p) >> 8) & 0xff;\ 400141cc406Sopenharmony_ci (d)[8] = (p) & 0xff 401141cc406Sopenharmony_ci#define SW_WNDDESCVAL SW_BODY_L 402141cc406Sopenharmony_ci#define SW_WNDDESCLEN(d,p) (d)[6] = ((p) >> 8) & 0xff; \ 403141cc406Sopenharmony_ci (d)[7] = (p) & 0xff 404141cc406Sopenharmony_ci#define SW_WNDID(d,p) (d)[0] = (p) 405141cc406Sopenharmony_ci#define SW_XRESDPI(d,p) (d)[2] = ((p) >> 8) & 0xff; \ 406141cc406Sopenharmony_ci (d)[3] = (p) & 0xff 407141cc406Sopenharmony_ci#define SW_YRESDPI(d,p) (d)[4] = ((p) >> 8) & 0xff; \ 408141cc406Sopenharmony_ci (d)[5] = (p) & 0xff 409141cc406Sopenharmony_ci#define SW_XPOSTL(d,p) (d)[6] = ((p) >> 24) & 0xff; \ 410141cc406Sopenharmony_ci (d)[7] = ((p) >> 16) & 0xff; \ 411141cc406Sopenharmony_ci (d)[8] = ((p) >> 8) & 0xff; \ 412141cc406Sopenharmony_ci (d)[9] = ((p)) & 0xff 413141cc406Sopenharmony_ci#define SW_YPOSTL(d,p) (d)[10] = ((p) >> 24) & 0xff; \ 414141cc406Sopenharmony_ci (d)[11] = ((p) >> 16) & 0xff; \ 415141cc406Sopenharmony_ci (d)[12] = ((p) >> 8) & 0xff; \ 416141cc406Sopenharmony_ci (d)[13] = (p) & 0xff 417141cc406Sopenharmony_ci#define SW_WNDWIDTH(d,p) (d)[14] = ((p) >> 24) & 0xff; \ 418141cc406Sopenharmony_ci (d)[15] = ((p) >> 16) & 0xff; \ 419141cc406Sopenharmony_ci (d)[16] = ((p) >> 8) & 0xff; \ 420141cc406Sopenharmony_ci (d)[17] = (p) & 0xff 421141cc406Sopenharmony_ci#define SW_WNDHEIGHT(d,p) (d)[18] = ((p) >> 24) & 0xff; \ 422141cc406Sopenharmony_ci (d)[19] = ((p) >> 16) & 0xff; \ 423141cc406Sopenharmony_ci (d)[20] = ((p) >> 8) & 0xff; \ 424141cc406Sopenharmony_ci (d)[21] = (p) & 0xff 425141cc406Sopenharmony_ci#define SW_BRIGHTNESS_M(d,p) (d)[22] = (p) 426141cc406Sopenharmony_ci#define SW_THRESHOLD(d,p) (d)[23] = (p) 427141cc406Sopenharmony_ci#define SW_CONTRAST_M(d,p) (d)[24] = (p) 428141cc406Sopenharmony_ci#define SW_IMGCOMP(d,p) (d)[25] = (p) & 0x0f /* take lineartfake */ 429141cc406Sopenharmony_ci /* into account */ 430141cc406Sopenharmony_ci#define SW_BITSPERPIXEL(d,p) (d)[26] = (p) 431141cc406Sopenharmony_ci#define SW_EXPOSURE_M(d,p) (d)[27] = (p) 432141cc406Sopenharmony_ci#define SW_EXTHT(d,p) (d)[28] |= (((p) << 7) & 0x80) 433141cc406Sopenharmony_ci#define SW_INTHTINDEX(d,p) (d)[28] |= ((p) & 0x7f) 434141cc406Sopenharmony_ci#define SW_RIF(d,p) (d)[29] |= (((p) << 7) & 0x80) 435141cc406Sopenharmony_ci#define SW_NOGAMMA(d,p) (d)[29] |= (((p) << 6) & 0x40) 436141cc406Sopenharmony_ci#define SW_SLOWSCAN(d,p) (d)[29] |= (((p) << 5) & 0x20) 437141cc406Sopenharmony_ci#define SW_LENS(d,p) (d)[30] = (p) 438141cc406Sopenharmony_ci#define SW_INFINITE(d,p) (d)[31] |= (((p) << 7) & 0x80) 439141cc406Sopenharmony_ci#define SW_STAY(d,p) (d)[31] |= (((p) << 6) & 0x40) 440141cc406Sopenharmony_ci#define SW_RAWDAT(d,p) (d)[31] |= (((p) << 5) & 0x20) 441141cc406Sopenharmony_ci#define SW_QUALITY(d,p) (d)[31] |= (((p) << 4) & 0x10) 442141cc406Sopenharmony_ci#define SW_FASTSCAN(d,p) (d)[31] |= (((p) << 3) & 0x08) 443141cc406Sopenharmony_ci#define SW_MEDIA(d,p) (d)[31] |= ((p) & 0x07) 444141cc406Sopenharmony_ci#define SW_JPEGENABLE(d,p) (d)[34] |= (((p) << 7) & 0x80) 445141cc406Sopenharmony_ci#define SW_JPEGALGOR(d,p) (d)[34] |= (((p) << 5) & 0x60) 446141cc406Sopenharmony_ci#define SW_JPEGMODE(d,p) (d)[34] |= (((p) << 3) & 0x18) 447141cc406Sopenharmony_ci#define SW_SHADOW_M(d,p) (d)[40] = (p) 448141cc406Sopenharmony_ci#define SW_MIDTONE_M(d,p) (d)[41] = (p) 449141cc406Sopenharmony_ci#define SW_HIGHLIGHT_M(d,p) (d)[42] = (p) 450141cc406Sopenharmony_ci#define SW_BRIGHTNESS_R(d,p) (d)[43] = (p) 451141cc406Sopenharmony_ci#define SW_CONTRAST_R(d,p) (d)[44] = (p) 452141cc406Sopenharmony_ci#define SW_EXPOSURE_R(d,p) (d)[45] = (p) 453141cc406Sopenharmony_ci#define SW_SHADOW_R(d,p) (d)[46] = (p) 454141cc406Sopenharmony_ci#define SW_MIDTONE_R(d,p) (d)[47] = (p) 455141cc406Sopenharmony_ci#define SW_HIGHLIGHT_R(d,p) (d)[48] = (p) 456141cc406Sopenharmony_ci#define SW_BRIGHTNESS_G(d,p) (d)[49] = (p) 457141cc406Sopenharmony_ci#define SW_CONTRAST_G(d,p) (d)[50] = (p) 458141cc406Sopenharmony_ci#define SW_EXPOSURE_G(d,p) (d)[51] = (p) 459141cc406Sopenharmony_ci#define SW_SHADOW_G(d,p) (d)[52] = (p) 460141cc406Sopenharmony_ci#define SW_MIDTONE_G(d,p) (d)[53] = (p) 461141cc406Sopenharmony_ci#define SW_HIGHLIGHT_G(d,p) (d)[54] = (p) 462141cc406Sopenharmony_ci#define SW_BRIGHTNESS_B(d,p) (d)[55] = (p) 463141cc406Sopenharmony_ci#define SW_CONTRAST_B(d,p) (d)[56] = (p) 464141cc406Sopenharmony_ci#define SW_EXPOSURE_B(d,p) (d)[57] = (p) 465141cc406Sopenharmony_ci#define SW_SHADOW_B(d,p) (d)[58] = (p) 466141cc406Sopenharmony_ci#define SW_MIDTONE_B(d,p) (d)[59] = (p) 467141cc406Sopenharmony_ci#define SW_HIGHLIGHT_B(d,p) (d)[60] = (p) 468141cc406Sopenharmony_ci 469141cc406Sopenharmony_ci 470141cc406Sopenharmony_ci/* READ IMAGE STATUS */ 471141cc406Sopenharmony_ci#define RIS_SET_CMD(d) (d)[0] = 0x28; (d)[1] = 0x00; (d)[2] = 0x83; \ 472141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[4] = 0x00; (d)[5] = 0x00; \ 473141cc406Sopenharmony_ci (d)[6] = 0x00; (d)[7] = 0x00; (d)[8] = 0x00; \ 474141cc406Sopenharmony_ci (d)[9] = 0x00 475141cc406Sopenharmony_ci#define RIS_CMD_L 10 476141cc406Sopenharmony_ci#define RIS_SET_PCORMAC(d,p) (d)[4] |= (((p) << 7) & 0x80) 477141cc406Sopenharmony_ci#define RIS_SET_COLOR(d,p) (d)[4] |= (((p) << 5) & 0x60) 478141cc406Sopenharmony_ci 479141cc406Sopenharmony_ci 480141cc406Sopenharmony_ci/* REQUEST SENSE */ 481141cc406Sopenharmony_ci#define RQS_CMD(d) (d)[0] = 0x03; (d)[1] = 0x00; (d)[2] = 0x00; \ 482141cc406Sopenharmony_ci (d)[3] = 0x00; (d)[5] = 0x00 483141cc406Sopenharmony_ci#define RQS_CMD_L 6 484141cc406Sopenharmony_ci#define RQS_ALLOCLENGTH(d,p) (d)[4] = (p) 485141cc406Sopenharmony_ci 486141cc406Sopenharmony_ci#define RQS_LENGTH(s) (s)[7] + 7 487141cc406Sopenharmony_ci 488141cc406Sopenharmony_ci#define RQS_SENSEKEY_NOSENSE 0x00 489141cc406Sopenharmony_ci#define RQS_SENSEKEY_HWERR 0x04 490141cc406Sopenharmony_ci#define RQS_SENSEKEY_ILLEGAL 0x05 491141cc406Sopenharmony_ci#define RQS_SENSEKEY_VENDOR 0x09 492141cc406Sopenharmony_ci#define RQS_SENSEKEY(s) ((s)[2] & 0x0f) 493141cc406Sopenharmony_ci 494141cc406Sopenharmony_ci#define RQS_INFO(s) ((s)[3] << 24) + ((s)[4] << 16) \ 495141cc406Sopenharmony_ci + ((s)[5] << 8) + ((s)[6]) 496141cc406Sopenharmony_ci#define RQS_ASL(s) (s)[7] 497141cc406Sopenharmony_ci#define RQS_REMAINBYTES(s) ((s)[8] << 24) + ((s)[9] << 16) \ 498141cc406Sopenharmony_ci + ((s)[10] << 8) + ((s)[11]) 499141cc406Sopenharmony_ci#define RQS_ASC(s) (s)[12] 500141cc406Sopenharmony_ci/* ASC == 0x40 */ 501141cc406Sopenharmony_ci#define RQS_ASCQ_CPUERR 0x81 502141cc406Sopenharmony_ci#define RQS_ASCQ_SRAMERR 0x82 503141cc406Sopenharmony_ci#define RQS_ASCQ_DRAMERR 0x84 504141cc406Sopenharmony_ci#define RQS_ASCQ_DCOFF 0x88 505141cc406Sopenharmony_ci#define RQS_ASCQ_GAIN 0x90 506141cc406Sopenharmony_ci#define RQS_ASCQ_POS 0xa0 507141cc406Sopenharmony_ci#define RQS_ASCQ(s) (s)[13] 508141cc406Sopenharmony_ci 509141cc406Sopenharmony_ci#define RQS_ASINFO(s) &((s)[18]) 510141cc406Sopenharmony_ci#define RQS_ASINFOLENGTH(s) (s)[7] - 11 511141cc406Sopenharmony_ci 512141cc406Sopenharmony_ci/******************************************************************************/ 513141cc406Sopenharmony_ci/* enumeration of Option Descriptors */ 514141cc406Sopenharmony_ci/******************************************************************************/ 515141cc406Sopenharmony_ci 516141cc406Sopenharmony_cienum Microtek2_Option 517141cc406Sopenharmony_ci{ 518141cc406Sopenharmony_ci /*0*/ 519141cc406Sopenharmony_ci OPT_NUM_OPTS = 0, 520141cc406Sopenharmony_ci 521141cc406Sopenharmony_ci /*1*/OPT_MODE_GROUP, 522141cc406Sopenharmony_ci OPT_SOURCE, 523141cc406Sopenharmony_ci OPT_MODE, 524141cc406Sopenharmony_ci OPT_BITDEPTH, 525141cc406Sopenharmony_ci OPT_RESOLUTION, 526141cc406Sopenharmony_ci OPT_Y_RESOLUTION, 527141cc406Sopenharmony_ci OPT_PREVIEW, 528141cc406Sopenharmony_ci 529141cc406Sopenharmony_ci /*9*/ OPT_GEOMETRY_GROUP, 530141cc406Sopenharmony_ci OPT_TL_X, /* top-left x */ 531141cc406Sopenharmony_ci OPT_TL_Y, /* top-left y */ 532141cc406Sopenharmony_ci OPT_BR_X, /* bottom-right x */ 533141cc406Sopenharmony_ci OPT_BR_Y, /* bottom-right y */ 534141cc406Sopenharmony_ci 535141cc406Sopenharmony_ci /*14*/ OPT_ENHANCEMENT_GROUP, 536141cc406Sopenharmony_ci OPT_BRIGHTNESS, 537141cc406Sopenharmony_ci OPT_CONTRAST, 538141cc406Sopenharmony_ci OPT_THRESHOLD, 539141cc406Sopenharmony_ci OPT_HALFTONE, 540141cc406Sopenharmony_ci OPT_AUTOADJUST, 541141cc406Sopenharmony_ci 542141cc406Sopenharmony_ci /*20*/ OPT_GAMMA_GROUP, 543141cc406Sopenharmony_ci OPT_GAMMA_MODE, 544141cc406Sopenharmony_ci OPT_GAMMA_SCALAR, 545141cc406Sopenharmony_ci OPT_GAMMA_SCALAR_R, 546141cc406Sopenharmony_ci OPT_GAMMA_SCALAR_G, 547141cc406Sopenharmony_ci OPT_GAMMA_SCALAR_B, 548141cc406Sopenharmony_ci OPT_GAMMA_CUSTOM, 549141cc406Sopenharmony_ci OPT_GAMMA_CUSTOM_R, 550141cc406Sopenharmony_ci OPT_GAMMA_CUSTOM_G, 551141cc406Sopenharmony_ci OPT_GAMMA_CUSTOM_B, 552141cc406Sopenharmony_ci OPT_GAMMA_BIND, 553141cc406Sopenharmony_ci 554141cc406Sopenharmony_ci /*31*/ OPT_SMH_GROUP, 555141cc406Sopenharmony_ci /* these options must appear in exactly this order, */ 556141cc406Sopenharmony_ci /* sane_control_option relies on it */ 557141cc406Sopenharmony_ci OPT_CHANNEL, 558141cc406Sopenharmony_ci OPT_SHADOW, 559141cc406Sopenharmony_ci OPT_MIDTONE, 560141cc406Sopenharmony_ci OPT_HIGHLIGHT, 561141cc406Sopenharmony_ci OPT_SHADOW_R, 562141cc406Sopenharmony_ci OPT_MIDTONE_R, 563141cc406Sopenharmony_ci OPT_HIGHLIGHT_R, 564141cc406Sopenharmony_ci OPT_SHADOW_G, 565141cc406Sopenharmony_ci OPT_MIDTONE_G, 566141cc406Sopenharmony_ci OPT_HIGHLIGHT_G, 567141cc406Sopenharmony_ci OPT_SHADOW_B, 568141cc406Sopenharmony_ci OPT_MIDTONE_B, 569141cc406Sopenharmony_ci OPT_HIGHLIGHT_B, 570141cc406Sopenharmony_ci OPT_EXPOSURE, 571141cc406Sopenharmony_ci OPT_EXPOSURE_R, 572141cc406Sopenharmony_ci OPT_EXPOSURE_G, 573141cc406Sopenharmony_ci OPT_EXPOSURE_B, 574141cc406Sopenharmony_ci 575141cc406Sopenharmony_ci /*49*/ OPT_SPECIAL, 576141cc406Sopenharmony_ci OPT_RESOLUTION_BIND, 577141cc406Sopenharmony_ci OPT_DISABLE_BACKTRACK, 578141cc406Sopenharmony_ci OPT_CALIB_BACKEND, 579141cc406Sopenharmony_ci OPT_LIGHTLID35, 580141cc406Sopenharmony_ci OPT_TOGGLELAMP, 581141cc406Sopenharmony_ci 582141cc406Sopenharmony_ci /*55*/ OPT_COLORBALANCE, 583141cc406Sopenharmony_ci OPT_BALANCE_R, 584141cc406Sopenharmony_ci OPT_BALANCE_G, 585141cc406Sopenharmony_ci OPT_BALANCE_B, 586141cc406Sopenharmony_ci OPT_BALANCE_FW, 587141cc406Sopenharmony_ci 588141cc406Sopenharmony_ci /*60*/ NUM_OPTIONS 589141cc406Sopenharmony_ci}; 590141cc406Sopenharmony_ci 591141cc406Sopenharmony_ci 592141cc406Sopenharmony_ci/******************************************************************************/ 593141cc406Sopenharmony_ci/* Description of options not included in saneopts.h */ 594141cc406Sopenharmony_ci/******************************************************************************/ 595141cc406Sopenharmony_ci 596141cc406Sopenharmony_ci#define M_TITLE_SCANMODEGRP SANE_I18N("Scan Mode") 597141cc406Sopenharmony_ci#define M_TITLE_GEOMGRP SANE_I18N("Geometry") 598141cc406Sopenharmony_ci#define M_TITLE_ENHANCEGRP SANE_I18N("Enhancement") 599141cc406Sopenharmony_ci#define M_TITLE_SMHGRP SANE_I18N("Shadow, midtone, highlight,"\ 600141cc406Sopenharmony_ci " exposure time"); 601141cc406Sopenharmony_ci#define M_TITLE_SPECIALGRP SANE_I18N("Special options") 602141cc406Sopenharmony_ci#define M_TITLE_COLBALANCEGRP SANE_I18N("Color balance") 603141cc406Sopenharmony_ci 604141cc406Sopenharmony_ci#define M_NAME_NOBACKTRACK "no-backtracking" 605141cc406Sopenharmony_ci#define M_TITLE_NOBACKTRACK SANE_I18N("Disable backtracking") 606141cc406Sopenharmony_ci#define M_DESC_NOBACKTRACK SANE_I18N("If checked the scanner does not" \ 607141cc406Sopenharmony_ci " perform backtracking") 608141cc406Sopenharmony_ci 609141cc406Sopenharmony_ci#define M_NAME_TOGGLELAMP "toggle-lamp" 610141cc406Sopenharmony_ci#define M_TITLE_TOGGLELAMP SANE_I18N("Toggle lamp of flatbed") 611141cc406Sopenharmony_ci#define M_DESC_TOGGLELAMP SANE_I18N("Toggles the lamp of the flatbed") 612141cc406Sopenharmony_ci 613141cc406Sopenharmony_ci#define M_NAME_CALIBBACKEND "backend-calibration" 614141cc406Sopenharmony_ci#define M_TITLE_CALIBBACKEND SANE_I18N("Calibration by backend") 615141cc406Sopenharmony_ci#define M_DESC_CALIBBACKEND SANE_I18N("If checked the color calibration" \ 616141cc406Sopenharmony_ci " before a scan is done by the backend") 617141cc406Sopenharmony_ci 618141cc406Sopenharmony_ci#define M_NAME_LIGHTLID35 "lightlid35" 619141cc406Sopenharmony_ci#define M_TITLE_LIGHTLID35 SANE_I18N("Use the lightlid-35mm adapter") 620141cc406Sopenharmony_ci#define M_DESC_LIGHTLID35 SANE_I18N("This option turns off the lamp of" \ 621141cc406Sopenharmony_ci " the flatbed during a scan") 622141cc406Sopenharmony_ci 623141cc406Sopenharmony_ci#define M_NAME_QUALITY_SCAN "quality-scan" 624141cc406Sopenharmony_ci#define M_TITLE_QUALITY_SCAN SANE_I18N("Quality scan") 625141cc406Sopenharmony_ci#define M_DESC_QUALITY_SCAN SANE_I18N("Highest quality but lower speed") 626141cc406Sopenharmony_ci 627141cc406Sopenharmony_ci#define M_NAME_FAST_SCAN "fast-scan" 628141cc406Sopenharmony_ci#define M_TITLE_FAST_SCAN SANE_I18N("Fast scan") 629141cc406Sopenharmony_ci#define M_DESC_FAST_SCAN SANE_I18N("Highest speed but lower quality") 630141cc406Sopenharmony_ci 631141cc406Sopenharmony_ci#define M_NAME_AUTOADJUST "lineart-auto-adjust" 632141cc406Sopenharmony_ci#define M_TITLE_AUTOADJUST SANE_I18N("Automatic adjustment of threshold") 633141cc406Sopenharmony_ci#define M_DESC_AUTOADJUST SANE_I18N("If checked the backend automatically"\ 634141cc406Sopenharmony_ci " tries to determine an optimal value for the" \ 635141cc406Sopenharmony_ci " threshold.") 636141cc406Sopenharmony_ci 637141cc406Sopenharmony_ci#define M_NAME_GAMMA_MODE "gamma-correction" 638141cc406Sopenharmony_ci#define M_TITLE_GAMMA_MODE SANE_I18N("Gamma correction") 639141cc406Sopenharmony_ci#define M_DESC_GAMMA_MODE SANE_I18N("Selects the gamma correction mode.") 640141cc406Sopenharmony_ci 641141cc406Sopenharmony_ci#define M_NAME_GAMMA_BIND "bind-gamma" 642141cc406Sopenharmony_ci#define M_TITLE_GAMMA_BIND SANE_I18N("Bind gamma") 643141cc406Sopenharmony_ci#define M_DESC_GAMMA_BIND SANE_I18N("Use same gamma values for all" \ 644141cc406Sopenharmony_ci " colour channels.") 645141cc406Sopenharmony_ci 646141cc406Sopenharmony_ci#define M_NAME_GAMMA_SCALAR "scalar-gamma" 647141cc406Sopenharmony_ci#define M_TITLE_GAMMA_SCALAR SANE_I18N("Scalar gamma") 648141cc406Sopenharmony_ci#define M_DESC_GAMMA_SCALAR SANE_I18N("Selects a value for scalar" \ 649141cc406Sopenharmony_ci " gamma correction.") 650141cc406Sopenharmony_ci 651141cc406Sopenharmony_ci#define M_NAME_GAMMA_SCALAR_R "scalar-gamma-r" 652141cc406Sopenharmony_ci#define M_TITLE_GAMMA_SCALAR_R SANE_I18N("Scalar gamma red") 653141cc406Sopenharmony_ci#define M_DESC_GAMMA_SCALAR_R SANE_I18N("Selects a value for scalar gamma" \ 654141cc406Sopenharmony_ci " correction (red channel)") 655141cc406Sopenharmony_ci 656141cc406Sopenharmony_ci#define M_NAME_GAMMA_SCALAR_G "scalar-gamma-g" 657141cc406Sopenharmony_ci#define M_TITLE_GAMMA_SCALAR_G SANE_I18N("Scalar gamma green") 658141cc406Sopenharmony_ci#define M_DESC_GAMMA_SCALAR_G SANE_I18N("Selects a value for scalar gamma" \ 659141cc406Sopenharmony_ci " correction (green channel)") 660141cc406Sopenharmony_ci 661141cc406Sopenharmony_ci#define M_NAME_GAMMA_SCALAR_B "scalar-gamma-b" 662141cc406Sopenharmony_ci#define M_TITLE_GAMMA_SCALAR_B SANE_I18N("Scalar gamma blue") 663141cc406Sopenharmony_ci#define M_DESC_GAMMA_SCALAR_B SANE_I18N("Selects a value for scalar gamma" \ 664141cc406Sopenharmony_ci " correction (blue channel)") 665141cc406Sopenharmony_ci 666141cc406Sopenharmony_ci#define M_NAME_CHANNEL "channel" 667141cc406Sopenharmony_ci#define M_TITLE_CHANNEL SANE_I18N("Channel") 668141cc406Sopenharmony_ci#define M_DESC_CHANNEL SANE_I18N("Selects the colour band, \"Master\"" \ 669141cc406Sopenharmony_ci " means that all colours are affected.") 670141cc406Sopenharmony_ci 671141cc406Sopenharmony_ci#define M_NAME_MIDTONE "midtone" 672141cc406Sopenharmony_ci#define M_TITLE_MIDTONE SANE_I18N("Midtone") 673141cc406Sopenharmony_ci#define M_DESC_MIDTONE SANE_I18N("Selects which radiance level should" \ 674141cc406Sopenharmony_ci " be considered \"50 % gray\".") 675141cc406Sopenharmony_ci 676141cc406Sopenharmony_ci#define M_NAME_MIDTONE_R "midtone-r" 677141cc406Sopenharmony_ci#define M_TITLE_MIDTONE_R SANE_I18N("Midtone for red") 678141cc406Sopenharmony_ci#define M_DESC_MIDTONE_R SANE_I18N("Selects which radiance level should" \ 679141cc406Sopenharmony_ci " be considered \"50 % red\".") 680141cc406Sopenharmony_ci 681141cc406Sopenharmony_ci#define M_NAME_MIDTONE_G "midtone-g" 682141cc406Sopenharmony_ci#define M_TITLE_MIDTONE_G SANE_I18N("Midtone for green") 683141cc406Sopenharmony_ci#define M_DESC_MIDTONE_G SANE_I18N("Selects which radiance level should" \ 684141cc406Sopenharmony_ci " be considered \"50 % green\".") 685141cc406Sopenharmony_ci 686141cc406Sopenharmony_ci#define M_NAME_MIDTONE_B "midtone-b" 687141cc406Sopenharmony_ci#define M_TITLE_MIDTONE_B SANE_I18N("Midtone for blue") 688141cc406Sopenharmony_ci#define M_DESC_MIDTONE_B SANE_I18N("Selects which radiance level should" \ 689141cc406Sopenharmony_ci " be considered \"50 % blue\".") 690141cc406Sopenharmony_ci 691141cc406Sopenharmony_ci#define M_NAME_BALANCE_R "balance-r" 692141cc406Sopenharmony_ci#define M_TITLE_BALANCE_R SANE_I18N("Red balance") 693141cc406Sopenharmony_ci#define M_DESC_BALANCE_R SANE_I18N("Balance factor for red. A value of" \ 694141cc406Sopenharmony_ci " 100% means no correction.") 695141cc406Sopenharmony_ci 696141cc406Sopenharmony_ci#define M_NAME_BALANCE_G "balance-g" 697141cc406Sopenharmony_ci#define M_TITLE_BALANCE_G SANE_I18N("Green balance") 698141cc406Sopenharmony_ci#define M_DESC_BALANCE_G SANE_I18N("Balance factor for green. A value of"\ 699141cc406Sopenharmony_ci " 100% means no correction.") 700141cc406Sopenharmony_ci 701141cc406Sopenharmony_ci#define M_NAME_BALANCE_B "balance-b" 702141cc406Sopenharmony_ci#define M_TITLE_BALANCE_B SANE_I18N("Blue balance") 703141cc406Sopenharmony_ci#define M_DESC_BALANCE_B SANE_I18N("Balance factor for blue. A value of" \ 704141cc406Sopenharmony_ci " 100% means no correction.") 705141cc406Sopenharmony_ci 706141cc406Sopenharmony_ci#define M_NAME_BALANCE_FW "balance-fw" 707141cc406Sopenharmony_ci#define M_TITLE_BALANCE_FW SANE_I18N("Firmware balance") 708141cc406Sopenharmony_ci#define M_DESC_BALANCE_FW SANE_I18N("Sets the color balance values to"\ 709141cc406Sopenharmony_ci " the firmware provided values.") 710141cc406Sopenharmony_ci 711141cc406Sopenharmony_ci/******************************************************************************/ 712141cc406Sopenharmony_ci/* Structure that contains global options */ 713141cc406Sopenharmony_ci/******************************************************************************/ 714141cc406Sopenharmony_ci 715141cc406Sopenharmony_citypedef struct Config_Options 716141cc406Sopenharmony_ci{ 717141cc406Sopenharmony_ci double strip_height; /* inch */ 718141cc406Sopenharmony_ci char *no_backtracking; /* enable/disable option for */ 719141cc406Sopenharmony_ci /* backtracking */ 720141cc406Sopenharmony_ci char *lightlid35; /* enable/disable lightlid35 option */ 721141cc406Sopenharmony_ci char *toggle_lamp; /* enable/disable lightlid35 option */ 722141cc406Sopenharmony_ci char *backend_calibration; /* calibration by backend */ 723141cc406Sopenharmony_ci char *auto_adjust; /* automatically choose threshold */ 724141cc406Sopenharmony_ci char *colorbalance_adjust; /* color balance can be modified */ 725141cc406Sopenharmony_ci} Config_Options; 726141cc406Sopenharmony_ci 727141cc406Sopenharmony_ci 728141cc406Sopenharmony_ci 729141cc406Sopenharmony_ci/******************************************************************************/ 730141cc406Sopenharmony_ci/* Structure that is temporarily used, when the config file is parsed */ 731141cc406Sopenharmony_ci/******************************************************************************/ 732141cc406Sopenharmony_ci 733141cc406Sopenharmony_citypedef struct Config_Temp 734141cc406Sopenharmony_ci{ 735141cc406Sopenharmony_ci struct Config_Temp *next; 736141cc406Sopenharmony_ci char *device; /* possible device name */ 737141cc406Sopenharmony_ci Config_Options opts; /* options belonging to this device name */ 738141cc406Sopenharmony_ci 739141cc406Sopenharmony_ci} Config_Temp; 740141cc406Sopenharmony_ci 741141cc406Sopenharmony_ci 742141cc406Sopenharmony_ci/******************************************************************************/ 743141cc406Sopenharmony_ci/* scanner hardware info (as discovered by INQUIRY and READ ATTRIBUTES) */ 744141cc406Sopenharmony_ci/******************************************************************************/ 745141cc406Sopenharmony_ci 746141cc406Sopenharmony_citypedef struct Microtek2_Info { 747141cc406Sopenharmony_ci /* from inquiry */ 748141cc406Sopenharmony_ci SANE_Byte device_qualifier; 749141cc406Sopenharmony_ci#define MI_DEVTYPE_SCANNER 0x06 750141cc406Sopenharmony_ci SANE_Byte device_type; 751141cc406Sopenharmony_ci#define MI_SCSI_II_VERSION 0x02 752141cc406Sopenharmony_ci SANE_Byte scsi_version; 753141cc406Sopenharmony_ci SANE_Char vendor[INQ_VENDOR_L + 1]; 754141cc406Sopenharmony_ci SANE_Char model[INQ_MODEL_L + 1]; 755141cc406Sopenharmony_ci SANE_Char revision[INQ_REV_L + 1]; 756141cc406Sopenharmony_ci SANE_Byte model_code; 757141cc406Sopenharmony_ci /* from read scanner attributes */ 758141cc406Sopenharmony_ci SANE_Bool color; 759141cc406Sopenharmony_ci#define MI_HAS_ONEPASS SANE_TRUE 760141cc406Sopenharmony_ci SANE_Bool onepass; 761141cc406Sopenharmony_ci /* the following 3 defines must correspond to byte 31 of SET WINDOW cmd */ 762141cc406Sopenharmony_ci#define MI_TYPE_FLATBED 0x01 763141cc406Sopenharmony_ci#define MI_TYPE_SHEEDFEED 0x02 764141cc406Sopenharmony_ci#define MI_TYPE_TRANSPARENCY 0x03 765141cc406Sopenharmony_ci SANE_Byte scanner_type; 766141cc406Sopenharmony_ci#define MI_HAS_FEPROM SANE_TRUE 767141cc406Sopenharmony_ci SANE_Bool feprom; 768141cc406Sopenharmony_ci /* MI_DATAFMT_X must correspond to Byte 0 in READ SCANNER ATTRIBUTE */ 769141cc406Sopenharmony_ci#define MI_DATAFMT_CHUNKY 1 770141cc406Sopenharmony_ci#define MI_DATAFMT_LPLCONCAT 2 771141cc406Sopenharmony_ci#define MI_DATAFMT_LPLSEGREG 3 772141cc406Sopenharmony_ci#define MI_DATAFMT_9800 4 773141cc406Sopenharmony_ci#define MI_DATAFMT_WORDCHUNKY 5 774141cc406Sopenharmony_ci SANE_Byte data_format; 775141cc406Sopenharmony_ci#define MI_COLSEQ_RED 0 776141cc406Sopenharmony_ci#define MI_COLSEQ_GREEN 1 777141cc406Sopenharmony_ci#define MI_COLSEQ_BLUE 2 778141cc406Sopenharmony_ci#define MI_COLSEQ_ILLEGAL 3 779141cc406Sopenharmony_ci uint8_t color_sequence[RSA_COLORSEQUENCE_L]; 780141cc406Sopenharmony_ci SANE_Bool new_image_status; 781141cc406Sopenharmony_ci#define MI_DATSEQ_RTOL 1 782141cc406Sopenharmony_ci uint8_t direction; 783141cc406Sopenharmony_ci SANE_Byte ccd_gap; 784141cc406Sopenharmony_ci SANE_Int max_xresolution; 785141cc406Sopenharmony_ci SANE_Int max_yresolution; 786141cc406Sopenharmony_ci SANE_Int geo_width; 787141cc406Sopenharmony_ci SANE_Int geo_height; 788141cc406Sopenharmony_ci SANE_Int opt_resolution; 789141cc406Sopenharmony_ci#define MI_HASDEPTH_NIBBLE 1 790141cc406Sopenharmony_ci#define MI_HASDEPTH_10 2 791141cc406Sopenharmony_ci#define MI_HASDEPTH_12 4 792141cc406Sopenharmony_ci#define MI_HASDEPTH_16 8 793141cc406Sopenharmony_ci#define MI_HASDEPTH_14 16 /*This is not in Byte 13 of 794141cc406Sopenharmony_ci scanner attributes but in 795141cc406Sopenharmony_ci byte 48-bit0*/ 796141cc406Sopenharmony_ci 797141cc406Sopenharmony_ci SANE_Byte depth; 798141cc406Sopenharmony_ci#define MI_LINEART_NONE(d) (((d) & 0x01) == 0) 799141cc406Sopenharmony_ci#define MI_HASMODE_LINEART 1 800141cc406Sopenharmony_ci#define MI_HASMODE_HALFTONE 2 801141cc406Sopenharmony_ci#define MI_HASMODE_GRAY 4 802141cc406Sopenharmony_ci#define MI_HASMODE_COLOR 8 803141cc406Sopenharmony_ci SANE_Byte scanmode; 804141cc406Sopenharmony_ci SANE_Int ccd_pixels; 805141cc406Sopenharmony_ci#define MI_LUTCAP_NONE(d) ((d) == 0) 806141cc406Sopenharmony_ci#define MI_LUTCAP_256B 1 807141cc406Sopenharmony_ci#define MI_LUTCAP_1024B 2 808141cc406Sopenharmony_ci#define MI_LUTCAP_1024W 4 809141cc406Sopenharmony_ci#define MI_LUTCAP_4096B 8 810141cc406Sopenharmony_ci#define MI_LUTCAP_4096W 16 811141cc406Sopenharmony_ci#define MI_LUTCAP_64k_W 32 812141cc406Sopenharmony_ci#define MI_LUTCAP_16k_W 64 813141cc406Sopenharmony_ci#define MI_LUTCAP_UNKNOWN 128 814141cc406Sopenharmony_ci SANE_Byte lut_cap; 815141cc406Sopenharmony_ci#define MI_HAS_DNLDPTRN SANE_TRUE 816141cc406Sopenharmony_ci SANE_Bool has_dnldptrn; 817141cc406Sopenharmony_ci SANE_Byte grain_slct; 818141cc406Sopenharmony_ci#define MI_OPTDEV_ADF 0x01 819141cc406Sopenharmony_ci#define MI_OPTDEV_TMA 0x02 820141cc406Sopenharmony_ci#define MI_OPTDEV_ADP 0x10 821141cc406Sopenharmony_ci#define MI_OPTDEV_APS 0x20 822141cc406Sopenharmony_ci#define MI_OPTDEV_STRIPE 0x40 823141cc406Sopenharmony_ci#define MI_OPTDEV_SLIDE 0x80 824141cc406Sopenharmony_ci SANE_Byte option_device; 825141cc406Sopenharmony_ci SANE_Int calib_white; 826141cc406Sopenharmony_ci SANE_Int calib_space; 827141cc406Sopenharmony_ci SANE_Byte nlens; 828141cc406Sopenharmony_ci SANE_Byte nwindows; 829141cc406Sopenharmony_ci SANE_Byte shtrnsferequ; 830141cc406Sopenharmony_ci#define MI_WHITE_SHADING_ONLY(x) (((x) & 0x20) == 0) 831141cc406Sopenharmony_ci#define MI_HAS_SCNBTTN SANE_TRUE 832141cc406Sopenharmony_ci SANE_Bool scnbuttn; 833141cc406Sopenharmony_ci#define MI_HAS_PIPOBUF SANE_TRUE 834141cc406Sopenharmony_ci SANE_Bool buftype; 835141cc406Sopenharmony_ci uint16_t balance[3]; /* balance factor for red, green */ 836141cc406Sopenharmony_ci /* and blue data */ 837141cc406Sopenharmony_ci uint16_t aps_maxframes; 838141cc406Sopenharmony_ci SANE_Int calib_divisor; /* e.g. the X12USL reads and sends */ 839141cc406Sopenharmony_ci /* shading at 1/2 * opt_resolution */ 840141cc406Sopenharmony_ci} Microtek2_Info; 841141cc406Sopenharmony_ci 842141cc406Sopenharmony_ci/******************************************************************************/ 843141cc406Sopenharmony_ci/* device structure (one for each device in config file) */ 844141cc406Sopenharmony_ci/******************************************************************************/ 845141cc406Sopenharmony_ci 846141cc406Sopenharmony_citypedef struct Microtek2_Device { 847141cc406Sopenharmony_ci struct Microtek2_Device *next; /* next, for linked list */ 848141cc406Sopenharmony_ci 849141cc406Sopenharmony_ci#define MD_SOURCE_FLATBED 0 850141cc406Sopenharmony_ci#define MD_SOURCE_ADF 1 851141cc406Sopenharmony_ci#define MD_SOURCE_TMA 2 852141cc406Sopenharmony_ci#define MD_SOURCE_SLIDE 3 853141cc406Sopenharmony_ci#define MD_SOURCE_STRIPE 4 854141cc406Sopenharmony_ci Microtek2_Info info[5]; /* detailed scanner spec */ 855141cc406Sopenharmony_ci SANE_Device sane; /* SANE generic device block */ 856141cc406Sopenharmony_ci char name[PATH_MAX]; /* name from config file */ 857141cc406Sopenharmony_ci 858141cc406Sopenharmony_ci SANE_Int *custom_gamma_table[4]; /* used for the custom gamma */ 859141cc406Sopenharmony_ci /* values before a scan starts */ 860141cc406Sopenharmony_ci /* the following two are derived from lut_cap */ 861141cc406Sopenharmony_ci int max_lut_size; /* in bytes */ 862141cc406Sopenharmony_ci int lut_entry_size; /* word or byte transfer in LUT */ 863141cc406Sopenharmony_ci uint8_t scan_source; 864141cc406Sopenharmony_ci double revision; 865141cc406Sopenharmony_ci 866141cc406Sopenharmony_ci /* basically the following two variables should go into the */ 867141cc406Sopenharmony_ci /* Microtek2_Scanner structure, but their values must be retained */ 868141cc406Sopenharmony_ci /* over several scans, and would be lost, if the application issues */ 869141cc406Sopenharmony_ci /* a sane_close. */ 870141cc406Sopenharmony_ci uint8_t *shading_table_w; /* shading table white */ 871141cc406Sopenharmony_ci uint8_t *shading_table_d; /* shading table dark */ 872141cc406Sopenharmony_ci uint8_t shading_table_contents; /* values like ms->mode */ 873141cc406Sopenharmony_ci /* the following structure describes the device status */ 874141cc406Sopenharmony_ci#define MD_TLAMP_ON 2 875141cc406Sopenharmony_ci#define MD_FLAMP_ON 1 876141cc406Sopenharmony_ci#define MD_NCALIB_ON 4 877141cc406Sopenharmony_ci#define MD_NTRACK_ON 8 878141cc406Sopenharmony_ci#define MD_STICK_ON 16 879141cc406Sopenharmony_ci#define MD_RESERVED17_ON 128 880141cc406Sopenharmony_ci#define MD_CURRENT_MODE_FLATBED 0 881141cc406Sopenharmony_ci struct { 882141cc406Sopenharmony_ci uint8_t sskip; 883141cc406Sopenharmony_ci uint8_t stick; 884141cc406Sopenharmony_ci uint8_t ntrack; 885141cc406Sopenharmony_ci uint8_t ncalib; 886141cc406Sopenharmony_ci uint8_t tlamp; 887141cc406Sopenharmony_ci uint8_t flamp; 888141cc406Sopenharmony_ci uint8_t reserved17; 889141cc406Sopenharmony_ci uint8_t rdyman; 890141cc406Sopenharmony_ci uint8_t trdy; 891141cc406Sopenharmony_ci uint8_t frdy; 892141cc406Sopenharmony_ci uint8_t adp; 893141cc406Sopenharmony_ci uint8_t detect; 894141cc406Sopenharmony_ci uint8_t adptime; 895141cc406Sopenharmony_ci uint8_t lensstatus; 896141cc406Sopenharmony_ci uint8_t aloff; 897141cc406Sopenharmony_ci uint8_t timeremain; 898141cc406Sopenharmony_ci uint8_t tmacnt; 899141cc406Sopenharmony_ci uint8_t paper; 900141cc406Sopenharmony_ci uint8_t adfcnt; 901141cc406Sopenharmony_ci uint8_t currentmode; 902141cc406Sopenharmony_ci uint8_t buttoncount; 903141cc406Sopenharmony_ci } status; 904141cc406Sopenharmony_ci 905141cc406Sopenharmony_ci /* The following defines are related to the model. Some models have */ 906141cc406Sopenharmony_ci /* more or less subtle deviations from the spec, which are indicated */ 907141cc406Sopenharmony_ci /* by these defines */ 908141cc406Sopenharmony_ci uint32_t model_flags; 909141cc406Sopenharmony_ci#define MD_NO_SLIDE_MODE 1 /* indicates that it has slide */ 910141cc406Sopenharmony_ci /* mode, but it does not */ 911141cc406Sopenharmony_ci#define MD_DATA_FORMAT_WRONG 2 /* X6 indicates wrong mode for TMA */ 912141cc406Sopenharmony_ci#define MD_NO_ENHANCEMENTS 4 /* image enhancements do not work */ 913141cc406Sopenharmony_ci /* (Brightness, contrast, .....) */ 914141cc406Sopenharmony_ci#define MD_RII_TWO_BYTES 8 /* return some image information */ 915141cc406Sopenharmony_ci /* in two byte */ 916141cc406Sopenharmony_ci#define MD_NO_GAMMA 16 /* if device does not accept */ 917141cc406Sopenharmony_ci /* gamma tables */ 918141cc406Sopenharmony_ci#define MD_PHANTOM336CX_TYPE_SHADING 32 /* Phantom 336cx type shading */ 919141cc406Sopenharmony_ci#define MD_READ_CONTROL_BIT 64 /* uses "read control bit" */ 920141cc406Sopenharmony_ci#define MD_PHANTOM_C6 128 /* It is a Phantom C6 */ 921141cc406Sopenharmony_ci#define MD_OFFSET_2 256 /* Image data starts 2 bytes */ 922141cc406Sopenharmony_ci /* from the beginning of a */ 923141cc406Sopenharmony_ci /* scanline */ 924141cc406Sopenharmony_ci#define MD_X6_SHORT_TRANSFER 512 /* X6 USB crashes if you read 925141cc406Sopenharmony_ci too much */ 926141cc406Sopenharmony_ci#define MD_NO_RIS_COMMAND 1024 /* doesn't like read_image_status */ 927141cc406Sopenharmony_ci#define MD_16BIT_TRANSFER 2048 /* transfers 10/12/14bit scans as */ 928141cc406Sopenharmony_ci /* 16bit data */ 929141cc406Sopenharmony_ci#define MD_CALIB_DIVISOR_600 4096 /* uses mi->calib_divisor=2 below 930141cc406Sopenharmony_ci 600dpi */ 931141cc406Sopenharmony_ci 932141cc406Sopenharmony_ci size_t n_control_bytes; /* for read_control_bits; the */ 933141cc406Sopenharmony_ci /* number is model dependent */ 934141cc406Sopenharmony_ci /* and can not be inquired */ 935141cc406Sopenharmony_ci uint32_t shading_length; /* length of the shading image */ 936141cc406Sopenharmony_ci /* Phantom 336cx, C6, ... */ 937141cc406Sopenharmony_ci uint8_t shading_depth; /* bit depth of shading image */ 938141cc406Sopenharmony_ci uint8_t controlbit_offset; /* first relevant control bit */ 939141cc406Sopenharmony_ci 940141cc406Sopenharmony_ci 941141cc406Sopenharmony_ci#define MD_MODESTRING_NUMS 4 942141cc406Sopenharmony_ci#define MD_MODESTRING_COLOR SANE_VALUE_SCAN_MODE_COLOR 943141cc406Sopenharmony_ci#define MD_MODESTRING_GRAY SANE_VALUE_SCAN_MODE_GRAY 944141cc406Sopenharmony_ci#define MD_MODESTRING_HALFTONE SANE_VALUE_SCAN_MODE_HALFTONE 945141cc406Sopenharmony_ci#define MD_MODESTRING_LINEART SANE_VALUE_SCAN_MODE_LINEART 946141cc406Sopenharmony_ci SANE_String_Const scanmode_list[MD_MODESTRING_NUMS + 1]; 947141cc406Sopenharmony_ci 948141cc406Sopenharmony_ci#define MD_DEPTHVAL_NUMS 6 949141cc406Sopenharmony_ci#define MD_DEPTHVAL_16 16 950141cc406Sopenharmony_ci#define MD_DEPTHVAL_14 14 951141cc406Sopenharmony_ci#define MD_DEPTHVAL_12 12 952141cc406Sopenharmony_ci#define MD_DEPTHVAL_10 10 953141cc406Sopenharmony_ci#define MD_DEPTHVAL_8 8 954141cc406Sopenharmony_ci#define MD_DEPTHVAL_4 4 955141cc406Sopenharmony_ci SANE_Int bitdepth_list[MD_DEPTHVAL_NUMS + 1]; 956141cc406Sopenharmony_ci 957141cc406Sopenharmony_ci#define MD_SOURCESTRING_NUMS 5 958141cc406Sopenharmony_ci#define MD_SOURCESTRING_FLATBED "Flatbed" 959141cc406Sopenharmony_ci#define MD_SOURCESTRING_ADF "ADF" 960141cc406Sopenharmony_ci#define MD_SOURCESTRING_TMA "TMA" 961141cc406Sopenharmony_ci#define MD_SOURCESTRING_STRIPE "Filmstrip" 962141cc406Sopenharmony_ci#define MD_SOURCESTRING_SLIDE "Slide" 963141cc406Sopenharmony_ci SANE_String_Const scansource_list[MD_SOURCESTRING_NUMS + 1]; 964141cc406Sopenharmony_ci 965141cc406Sopenharmony_ci#define MD_HALFTONE_NUMS 12 966141cc406Sopenharmony_ci#define MD_HALFTONE0 "53-dot screen (53 gray levels)" 967141cc406Sopenharmony_ci#define MD_HALFTONE1 "Horiz. screen (65 gray levels)" 968141cc406Sopenharmony_ci#define MD_HALFTONE2 "Vert. screen (65 gray levels)" 969141cc406Sopenharmony_ci#define MD_HALFTONE3 "Mixed page (33 gray levels)" 970141cc406Sopenharmony_ci#define MD_HALFTONE4 "71-dot screen (29 gray levels)" 971141cc406Sopenharmony_ci#define MD_HALFTONE5 "60-dot #1 (26 gray levels)" 972141cc406Sopenharmony_ci#define MD_HALFTONE6 "60-dot #2 (26 gray levels)" 973141cc406Sopenharmony_ci#define MD_HALFTONE7 "Fine detail #1 (17 gray levels)" 974141cc406Sopenharmony_ci#define MD_HALFTONE8 "Fine detail #2 (17 gray levels)" 975141cc406Sopenharmony_ci#define MD_HALFTONE9 "Slant line (17 gray levels)" 976141cc406Sopenharmony_ci#define MD_HALFTONE10 "Posterizing (10 gray levels)" 977141cc406Sopenharmony_ci#define MD_HALFTONE11 "High Contrast (5 gray levels)" 978141cc406Sopenharmony_ci SANE_String_Const halftone_mode_list[MD_HALFTONE_NUMS + 1]; 979141cc406Sopenharmony_ci 980141cc406Sopenharmony_ci#define MD_CHANNEL_NUMS 4 981141cc406Sopenharmony_ci#define MD_CHANNEL_MASTER "Master" 982141cc406Sopenharmony_ci#define MD_CHANNEL_RED "Red" 983141cc406Sopenharmony_ci#define MD_CHANNEL_GREEN "Green" 984141cc406Sopenharmony_ci#define MD_CHANNEL_BLUE "Blue" 985141cc406Sopenharmony_ci SANE_String_Const channel_list[MD_CHANNEL_NUMS + 1]; 986141cc406Sopenharmony_ci 987141cc406Sopenharmony_ci#define MD_GAMMAMODE_NUMS 3 988141cc406Sopenharmony_ci#define MD_GAMMAMODE_LINEAR "None" 989141cc406Sopenharmony_ci#define MD_GAMMAMODE_SCALAR "Scalar" 990141cc406Sopenharmony_ci#define MD_GAMMAMODE_CUSTOM "Custom" 991141cc406Sopenharmony_ci SANE_String_Const gammamode_list[MD_GAMMAMODE_NUMS + 1]; 992141cc406Sopenharmony_ci 993141cc406Sopenharmony_ci SANE_Range x_res_range_dpi; /* X resolution in dpi */ 994141cc406Sopenharmony_ci SANE_Range y_res_range_dpi; /* Y resolution in dpi */ 995141cc406Sopenharmony_ci SANE_Range x_range_mm; /* scan width in mm */ 996141cc406Sopenharmony_ci SANE_Range y_range_mm; /* scan height in mm */ 997141cc406Sopenharmony_ci SANE_Range percentage_range; /* for brightness, shadow, ... */ 998141cc406Sopenharmony_ci SANE_Range custom_gamma_range; /* for custom gamma values */ 999141cc406Sopenharmony_ci SANE_Range scalar_gamma_range; /* for scalar gamma values */ 1000141cc406Sopenharmony_ci SANE_Range shadow_range; /* shadow of blue channel */ 1001141cc406Sopenharmony_ci SANE_Range midtone_range; /* midtone shadow of blue channel */ 1002141cc406Sopenharmony_ci SANE_Range exposure_range; /* for lengthening exposure time */ 1003141cc406Sopenharmony_ci SANE_Range highlight_range; /* highlight of master channel */ 1004141cc406Sopenharmony_ci SANE_Range threshold_range; /* 1 - 255 */ 1005141cc406Sopenharmony_ci SANE_Range balance_range; /* for user provided color balance */ 1006141cc406Sopenharmony_ci Config_Options opts; /* options from the config file */ 1007141cc406Sopenharmony_ci SANE_Word opt_backend_calib_default; /* corresponds to scanner model */ 1008141cc406Sopenharmony_ci SANE_Word opt_no_backtrack_default; /* corresponds to scanner model */ 1009141cc406Sopenharmony_ci} Microtek2_Device; 1010141cc406Sopenharmony_ci 1011141cc406Sopenharmony_ci 1012141cc406Sopenharmony_ci 1013141cc406Sopenharmony_ci/******************************************************************************/ 1014141cc406Sopenharmony_ci/* scanner structure (one for each device in use) */ 1015141cc406Sopenharmony_ci/* ....all the state needed to define a scan request */ 1016141cc406Sopenharmony_ci/******************************************************************************/ 1017141cc406Sopenharmony_ci 1018141cc406Sopenharmony_citypedef struct Microtek2_Scanner { 1019141cc406Sopenharmony_ci struct Microtek2_Scanner *next; /* for linked list */ 1020141cc406Sopenharmony_ci Microtek2_Device *dev; /* raw device info */ 1021141cc406Sopenharmony_ci Option_Value val[NUM_OPTIONS + 1]; /* option values for session */ 1022141cc406Sopenharmony_ci SANE_Parameters params; /* format, lastframe, lines, depth, ppl, bpl */ 1023141cc406Sopenharmony_ci SANE_Option_Descriptor sod[NUM_OPTIONS + 1]; /* option list for session */ 1024141cc406Sopenharmony_ci 1025141cc406Sopenharmony_ci uint8_t *gamma_table; 1026141cc406Sopenharmony_ci uint8_t *shading_image; /* used for shading image */ 1027141cc406Sopenharmony_ci uint8_t *condensed_shading_w; /* used when a model uses "read */ 1028141cc406Sopenharmony_ci uint8_t *condensed_shading_d; /* control bit", stores the relevant */ 1029141cc406Sopenharmony_ci /* shading pixels for each color */ 1030141cc406Sopenharmony_ci uint8_t *temporary_buffer; /* used when automatic adjustment */ 1031141cc406Sopenharmony_ci /* is selected */ 1032141cc406Sopenharmony_ci char *gamma_mode; /* none, linear or custom */ 1033141cc406Sopenharmony_ci 1034141cc406Sopenharmony_ci/* the following defines must correspond to byte 25 of SET WINDOW body */ 1035141cc406Sopenharmony_ci#define MS_MODE_LINEART 0x00 1036141cc406Sopenharmony_ci#define MS_MODE_HALFTONE 0x01 1037141cc406Sopenharmony_ci#define MS_MODE_GRAY 0x02 1038141cc406Sopenharmony_ci#define MS_MODE_LINEARTFAKE 0x12 /* no real mode */ 1039141cc406Sopenharmony_ci#define MS_MODE_COLOR 0x05 1040141cc406Sopenharmony_ci 1041141cc406Sopenharmony_ci/* the following defines must correspond to byte 31 of SET WINDOW body */ 1042141cc406Sopenharmony_ci#define MS_SOURCE_FLATBED 0x00 1043141cc406Sopenharmony_ci#define MS_SOURCE_ADF 0x01 1044141cc406Sopenharmony_ci#define MS_SOURCE_TMA 0x02 1045141cc406Sopenharmony_ci#define MS_SOURCE_STRIPE 0x05 1046141cc406Sopenharmony_ci#define MS_SOURCE_SLIDE 0x06 1047141cc406Sopenharmony_ci 1048141cc406Sopenharmony_ci SANE_Int mode; 1049141cc406Sopenharmony_ci SANE_Int depth; 1050141cc406Sopenharmony_ci SANE_Int x_resolution_dpi; 1051141cc406Sopenharmony_ci SANE_Int y_resolution_dpi; 1052141cc406Sopenharmony_ci SANE_Int x1_dots; /* x-position in units of optical resolution */ 1053141cc406Sopenharmony_ci SANE_Int y1_dots; /* same for y-position */ 1054141cc406Sopenharmony_ci SANE_Int width_dots; /* scan width in units of optical resolution */ 1055141cc406Sopenharmony_ci SANE_Int height_dots; /* same for height */ 1056141cc406Sopenharmony_ci uint8_t brightness_m; 1057141cc406Sopenharmony_ci uint8_t contrast_m; 1058141cc406Sopenharmony_ci uint8_t exposure_m; 1059141cc406Sopenharmony_ci uint8_t shadow_m; 1060141cc406Sopenharmony_ci uint8_t midtone_m; 1061141cc406Sopenharmony_ci uint8_t highlight_m; 1062141cc406Sopenharmony_ci uint8_t brightness_r; 1063141cc406Sopenharmony_ci uint8_t contrast_r; 1064141cc406Sopenharmony_ci uint8_t exposure_r; 1065141cc406Sopenharmony_ci uint8_t shadow_r; 1066141cc406Sopenharmony_ci uint8_t midtone_r; 1067141cc406Sopenharmony_ci uint8_t highlight_r; 1068141cc406Sopenharmony_ci uint8_t brightness_g; 1069141cc406Sopenharmony_ci uint8_t contrast_g; 1070141cc406Sopenharmony_ci uint8_t exposure_g; 1071141cc406Sopenharmony_ci uint8_t shadow_g; 1072141cc406Sopenharmony_ci uint8_t midtone_g; 1073141cc406Sopenharmony_ci uint8_t highlight_g; 1074141cc406Sopenharmony_ci uint8_t brightness_b; 1075141cc406Sopenharmony_ci uint8_t contrast_b; 1076141cc406Sopenharmony_ci uint8_t exposure_b; 1077141cc406Sopenharmony_ci uint8_t shadow_b; 1078141cc406Sopenharmony_ci uint8_t midtone_b; 1079141cc406Sopenharmony_ci uint8_t highlight_b; 1080141cc406Sopenharmony_ci uint8_t threshold; 1081141cc406Sopenharmony_ci 1082141cc406Sopenharmony_ci SANE_Bool use_external_ht; 1083141cc406Sopenharmony_ci SANE_Byte internal_ht_index; 1084141cc406Sopenharmony_ci uint8_t stay; 1085141cc406Sopenharmony_ci uint8_t rawdat; 1086141cc406Sopenharmony_ci SANE_Bool quality; 1087141cc406Sopenharmony_ci SANE_Bool fastscan; 1088141cc406Sopenharmony_ci SANE_Byte scan_source; 1089141cc406Sopenharmony_ci uint8_t no_backtracking; 1090141cc406Sopenharmony_ci uint8_t lightlid35; 1091141cc406Sopenharmony_ci uint8_t auto_adjust; 1092141cc406Sopenharmony_ci uint8_t calib_backend; 1093141cc406Sopenharmony_ci uint8_t colorbalance_adjust; 1094141cc406Sopenharmony_ci int current_pass; /* current pass if 3-pass scan */ 1095141cc406Sopenharmony_ci int lut_size; /* size of gamma lookup table */ 1096141cc406Sopenharmony_ci int lut_entry_size; /* size of one entry in lookup table */ 1097141cc406Sopenharmony_ci uint32_t lut_size_bytes; /* size of LUT in bytes */ 1098141cc406Sopenharmony_ci uint8_t word; /* word transfer, used in some read cmds */ 1099141cc406Sopenharmony_ci /* MS_COLOR_X must correspond to color field in READ IMAGE STATUS */ 1100141cc406Sopenharmony_ci#define MS_COLOR_RED 0 1101141cc406Sopenharmony_ci#define MS_COLOR_GREEN 1 1102141cc406Sopenharmony_ci#define MS_COLOR_BLUE 2 1103141cc406Sopenharmony_ci#define MS_COLOR_ALL 3 1104141cc406Sopenharmony_ci uint8_t current_color; /* for gamma calc. and 3-pass scanners */ 1105141cc406Sopenharmony_ci uint8_t current_read_color; /* dto, for RI and RIS */ 1106141cc406Sopenharmony_ci uint8_t dark; /* is 1 for reading dark shading */ 1107141cc406Sopenharmony_ci uint32_t ppl; /* pixels per line as returned by RII */ 1108141cc406Sopenharmony_ci uint32_t bpl; /* bytes per line as returned by RII */ 1109141cc406Sopenharmony_ci uint32_t remaining_bytes; /* remaining bytes as returned by RII */ 1110141cc406Sopenharmony_ci uint32_t real_remaining_bytes;/* bytes to transfer to the frontend */ 1111141cc406Sopenharmony_ci uint32_t real_bpl; /* bpl to transfer to the frontend */ 1112141cc406Sopenharmony_ci SANE_Int src_remaining_lines; /* remaining lines to read */ 1113141cc406Sopenharmony_ci SANE_Int src_lines_to_read; /* actual number of lines read */ 1114141cc406Sopenharmony_ci SANE_Int src_max_lines; /* maximum number of lines that fit */ 1115141cc406Sopenharmony_ci /* into the scsi buffer */ 1116141cc406Sopenharmony_ci /* sent to the frontend */ 1117141cc406Sopenharmony_ci int bits_per_pixel_in; /* bits per pixel transferred from scanner */ 1118141cc406Sopenharmony_ci int bits_per_pixel_out; /* bits per pixel transf. to frontend */ 1119141cc406Sopenharmony_ci uint32_t src_buffer_size; /* size of the buffer */ 1120141cc406Sopenharmony_ci int transfer_length; /* transfer length for RI command */ 1121141cc406Sopenharmony_ci uint8_t balance[3]; /* user provided balance factor for */ 1122141cc406Sopenharmony_ci /* red, green and blue data */ 1123141cc406Sopenharmony_ci struct { 1124141cc406Sopenharmony_ci uint8_t *src_buffer[2]; /* two buffers because of CCD gap */ 1125141cc406Sopenharmony_ci uint8_t *src_buf; 1126141cc406Sopenharmony_ci int current_src; 1127141cc406Sopenharmony_ci SANE_Int free_lines; 1128141cc406Sopenharmony_ci SANE_Int free_max_lines; 1129141cc406Sopenharmony_ci uint8_t *current_pos[3]; /* actual position in the source buffer */ 1130141cc406Sopenharmony_ci int planes[2][3]; /* # of red, green, blue planes in the */ 1131141cc406Sopenharmony_ci /* current source buffer and leftover */ 1132141cc406Sopenharmony_ci /* planes from previous "read image" */ 1133141cc406Sopenharmony_ci } buf; 1134141cc406Sopenharmony_ci 1135141cc406Sopenharmony_ci SANE_Bool onepass; 1136141cc406Sopenharmony_ci 1137141cc406Sopenharmony_ci size_t n_control_bytes; /* for READ CONTROL BITS */ 1138141cc406Sopenharmony_ci uint8_t *control_bytes; /* pointer to the result */ 1139141cc406Sopenharmony_ci 1140141cc406Sopenharmony_ci int scanning; /* true == between sane_start & sane_read=EOF */ 1141141cc406Sopenharmony_ci int cancelled; 1142141cc406Sopenharmony_ci int sfd; /* SCSI filedescriptor */ 1143141cc406Sopenharmony_ci int fd[2]; /* file descriptors for pipe */ 1144141cc406Sopenharmony_ci SANE_Pid pid; /* pid of child process */ 1145141cc406Sopenharmony_ci FILE *fp; 1146141cc406Sopenharmony_ci 1147141cc406Sopenharmony_ci} Microtek2_Scanner; 1148141cc406Sopenharmony_ci 1149141cc406Sopenharmony_ci/******************************************************************************/ 1150141cc406Sopenharmony_ci/* Function prototypes */ 1151141cc406Sopenharmony_ci/******************************************************************************/ 1152141cc406Sopenharmony_ci 1153141cc406Sopenharmony_cistatic SANE_Status 1154141cc406Sopenharmony_ciadd_device_list(SANE_String_Const, Microtek2_Device **); 1155141cc406Sopenharmony_ci 1156141cc406Sopenharmony_cistatic SANE_Status 1157141cc406Sopenharmony_ciattach(Microtek2_Device *); 1158141cc406Sopenharmony_ci 1159141cc406Sopenharmony_cistatic SANE_Status 1160141cc406Sopenharmony_ciattach_one (const char *); 1161141cc406Sopenharmony_ci 1162141cc406Sopenharmony_cistatic SANE_Status 1163141cc406Sopenharmony_ciauto_adjust_proc_data (Microtek2_Scanner *, uint8_t **); 1164141cc406Sopenharmony_ci 1165141cc406Sopenharmony_cistatic SANE_Status 1166141cc406Sopenharmony_cicalc_cx_shading_line(Microtek2_Scanner *); /* (KF) new */ 1167141cc406Sopenharmony_ci 1168141cc406Sopenharmony_cistatic SANE_Status 1169141cc406Sopenharmony_cicalculate_gamma(Microtek2_Scanner *, uint8_t *, int, char *); 1170141cc406Sopenharmony_ci 1171141cc406Sopenharmony_cistatic SANE_Status 1172141cc406Sopenharmony_cicalculate_sane_params(Microtek2_Scanner *); 1173141cc406Sopenharmony_ci 1174141cc406Sopenharmony_cistatic SANE_Status 1175141cc406Sopenharmony_cicancel_scan(Microtek2_Scanner *); 1176141cc406Sopenharmony_ci 1177141cc406Sopenharmony_cistatic SANE_Status 1178141cc406Sopenharmony_cicheck_inquiry(Microtek2_Device *, SANE_String *); 1179141cc406Sopenharmony_ci 1180141cc406Sopenharmony_cistatic void 1181141cc406Sopenharmony_cicheck_option(const char *, Config_Options *); 1182141cc406Sopenharmony_ci 1183141cc406Sopenharmony_cistatic SANE_Status 1184141cc406Sopenharmony_cichunky_copy_pixels(Microtek2_Scanner *, uint8_t *); 1185141cc406Sopenharmony_ci 1186141cc406Sopenharmony_cistatic SANE_Status 1187141cc406Sopenharmony_cichunky_proc_data(Microtek2_Scanner *); 1188141cc406Sopenharmony_ci 1189141cc406Sopenharmony_ci#if 0 1190141cc406Sopenharmony_cistatic void 1191141cc406Sopenharmony_cichunky_set_exposure(uint8_t *, uint32_t, uint8_t, uint8_t, int); 1192141cc406Sopenharmony_ci#endif 1193141cc406Sopenharmony_ci 1194141cc406Sopenharmony_cistatic void 1195141cc406Sopenharmony_cicleanup_scanner(Microtek2_Scanner *); 1196141cc406Sopenharmony_ci 1197141cc406Sopenharmony_cistatic SANE_Status 1198141cc406Sopenharmony_cicondense_shading(Microtek2_Scanner *); 1199141cc406Sopenharmony_ci 1200141cc406Sopenharmony_ci#ifdef HAVE_AUTHORIZATION 1201141cc406Sopenharmony_cistatic SANE_Status 1202141cc406Sopenharmony_cido_authorization(char *); 1203141cc406Sopenharmony_ci#endif 1204141cc406Sopenharmony_ci 1205141cc406Sopenharmony_cistatic SANE_Status 1206141cc406Sopenharmony_ciread_shading_image(Microtek2_Scanner *); 1207141cc406Sopenharmony_ci 1208141cc406Sopenharmony_cistatic SANE_Status 1209141cc406Sopenharmony_cidump_area(uint8_t *, int, char *); 1210141cc406Sopenharmony_ci 1211141cc406Sopenharmony_cistatic SANE_Status 1212141cc406Sopenharmony_cidump_area2(uint8_t *, int, char *); 1213141cc406Sopenharmony_ci 1214141cc406Sopenharmony_ci/* currently not used */ 1215141cc406Sopenharmony_ci#if 0 1216141cc406Sopenharmony_cistatic SANE_Status 1217141cc406Sopenharmony_cidump_to_file(uint8_t *, int, char *, char *); 1218141cc406Sopenharmony_ci#endif 1219141cc406Sopenharmony_ci 1220141cc406Sopenharmony_cistatic SANE_Status 1221141cc406Sopenharmony_cidump_attributes(Microtek2_Info *); 1222141cc406Sopenharmony_ci 1223141cc406Sopenharmony_cistatic void 1224141cc406Sopenharmony_ciget_calib_params(Microtek2_Scanner *); 1225141cc406Sopenharmony_ci 1226141cc406Sopenharmony_cistatic SANE_Status 1227141cc406Sopenharmony_ciget_cshading_values(Microtek2_Scanner *,uint8_t, uint32_t, float, int, 1228141cc406Sopenharmony_ci float *, float *); /* (KF) new */ 1229141cc406Sopenharmony_cistatic SANE_Status 1230141cc406Sopenharmony_ciget_scan_mode_and_depth(Microtek2_Scanner *, int *, SANE_Int *, int *, int *); 1231141cc406Sopenharmony_ci 1232141cc406Sopenharmony_cistatic SANE_Status 1233141cc406Sopenharmony_ciget_scan_parameters(Microtek2_Scanner *); 1234141cc406Sopenharmony_ci 1235141cc406Sopenharmony_cistatic SANE_Status 1236141cc406Sopenharmony_ciget_lut_size(Microtek2_Info *, int *, int *); 1237141cc406Sopenharmony_ci 1238141cc406Sopenharmony_cistatic SANE_Status 1239141cc406Sopenharmony_cigray_copy_pixels(Microtek2_Scanner *ms, uint8_t *, int, int); 1240141cc406Sopenharmony_ci 1241141cc406Sopenharmony_cistatic SANE_Status 1242141cc406Sopenharmony_cigray_proc_data(Microtek2_Scanner *); 1243141cc406Sopenharmony_ci 1244141cc406Sopenharmony_ci#if 0 1245141cc406Sopenharmony_cistatic void 1246141cc406Sopenharmony_cigray_set_exposure(uint8_t *, uint32_t, uint8_t, uint8_t); 1247141cc406Sopenharmony_ci#endif 1248141cc406Sopenharmony_ci 1249141cc406Sopenharmony_cistatic SANE_Status 1250141cc406Sopenharmony_ciinit_options(Microtek2_Scanner *, uint8_t); 1251141cc406Sopenharmony_ci 1252141cc406Sopenharmony_cistatic SANE_Status 1253141cc406Sopenharmony_cilineartfake_copy_pixels(Microtek2_Scanner *, uint8_t *, uint32_t, uint8_t, 1254141cc406Sopenharmony_ci int, FILE *); 1255141cc406Sopenharmony_ci 1256141cc406Sopenharmony_cistatic SANE_Status 1257141cc406Sopenharmony_cilineartfake_proc_data(Microtek2_Scanner *); 1258141cc406Sopenharmony_ci 1259141cc406Sopenharmony_cistatic SANE_Status 1260141cc406Sopenharmony_cilplconcat_copy_pixels(Microtek2_Scanner *, uint8_t **, int, int); 1261141cc406Sopenharmony_ci 1262141cc406Sopenharmony_cistatic SANE_Status 1263141cc406Sopenharmony_cilplconcat_proc_data(Microtek2_Scanner *ms); 1264141cc406Sopenharmony_ci 1265141cc406Sopenharmony_cistatic size_t 1266141cc406Sopenharmony_cimax_string_size (const SANE_String_Const * /* strings[] */); 1267141cc406Sopenharmony_ci 1268141cc406Sopenharmony_cistatic void 1269141cc406Sopenharmony_ciparse_config_file(FILE *, Config_Temp **); 1270141cc406Sopenharmony_ci 1271141cc406Sopenharmony_cistatic SANE_Status 1272141cc406Sopenharmony_ciprepare_buffers(Microtek2_Scanner *); 1273141cc406Sopenharmony_ci 1274141cc406Sopenharmony_cistatic SANE_Status 1275141cc406Sopenharmony_ciprepare_shading_data(Microtek2_Scanner *, uint32_t, uint8_t **); 1276141cc406Sopenharmony_ci 1277141cc406Sopenharmony_cistatic SANE_Status 1278141cc406Sopenharmony_ciproc_onebit_data(Microtek2_Scanner *); 1279141cc406Sopenharmony_ci 1280141cc406Sopenharmony_cistatic SANE_Status 1281141cc406Sopenharmony_ciread_cx_shading_image(Microtek2_Scanner *); 1282141cc406Sopenharmony_ci 1283141cc406Sopenharmony_cistatic SANE_Status 1284141cc406Sopenharmony_ciread_cx_shading(Microtek2_Scanner *); 1285141cc406Sopenharmony_ci 1286141cc406Sopenharmony_cistatic int 1287141cc406Sopenharmony_cireader_process(void *); 1288141cc406Sopenharmony_ci 1289141cc406Sopenharmony_cistatic SANE_Status 1290141cc406Sopenharmony_cirestore_gamma_options(SANE_Option_Descriptor *, Option_Value *); 1291141cc406Sopenharmony_ci 1292141cc406Sopenharmony_cistatic SANE_Status 1293141cc406Sopenharmony_cisegreg_copy_pixels(Microtek2_Scanner *); 1294141cc406Sopenharmony_ci 1295141cc406Sopenharmony_cistatic SANE_Status 1296141cc406Sopenharmony_cisegreg_proc_data(Microtek2_Scanner *ms); 1297141cc406Sopenharmony_ci 1298141cc406Sopenharmony_cistatic void 1299141cc406Sopenharmony_ciset_exposure(Microtek2_Scanner *); 1300141cc406Sopenharmony_ci 1301141cc406Sopenharmony_cistatic SANE_Status 1302141cc406Sopenharmony_ciset_option_dependencies(Microtek2_Scanner *, 1303141cc406Sopenharmony_ci SANE_Option_Descriptor *, Option_Value *); 1304141cc406Sopenharmony_ci 1305141cc406Sopenharmony_cistatic SANE_Status 1306141cc406Sopenharmony_cishading_function(Microtek2_Scanner *, uint8_t *); 1307141cc406Sopenharmony_ci 1308141cc406Sopenharmony_cistatic void 1309141cc406Sopenharmony_cisignal_handler (int); 1310141cc406Sopenharmony_ci 1311141cc406Sopenharmony_cistatic SANE_Status 1312141cc406Sopenharmony_ciwordchunky_copy_pixels(uint8_t *, uint32_t, int, FILE *); 1313141cc406Sopenharmony_ci 1314141cc406Sopenharmony_cistatic SANE_Status 1315141cc406Sopenharmony_ciwordchunky_proc_data(Microtek2_Scanner *); 1316141cc406Sopenharmony_ci 1317141cc406Sopenharmony_citypedef int (*qsortfunc)(const void *, const void *); 1318141cc406Sopenharmony_ci 1319141cc406Sopenharmony_cistatic int compare_func_16(const uint16_t *p1, uint16_t *p2) 1320141cc406Sopenharmony_ci { 1321141cc406Sopenharmony_ci return ( *p1 - *p2 ); 1322141cc406Sopenharmony_ci } 1323141cc406Sopenharmony_ci 1324141cc406Sopenharmony_ci 1325141cc406Sopenharmony_ci/******************************************************************************/ 1326141cc406Sopenharmony_ci/* Function prototypes for basic SCSI commands */ 1327141cc406Sopenharmony_ci/******************************************************************************/ 1328141cc406Sopenharmony_ci 1329141cc406Sopenharmony_cistatic SANE_Status 1330141cc406Sopenharmony_ciscsi_inquiry(Microtek2_Info *, char *); 1331141cc406Sopenharmony_ci 1332141cc406Sopenharmony_cistatic SANE_Status 1333141cc406Sopenharmony_ciscsi_read_attributes(Microtek2_Info *, char *, uint8_t); 1334141cc406Sopenharmony_ci 1335141cc406Sopenharmony_cistatic SANE_Status 1336141cc406Sopenharmony_ciscsi_read_control_bits(Microtek2_Scanner *); 1337141cc406Sopenharmony_ci 1338141cc406Sopenharmony_ci/* currently not used */ 1339141cc406Sopenharmony_ci/* static SANE_Status 1340141cc406Sopenharmony_ciscsi_read_gamma(Microtek2_Scanner *); */ 1341141cc406Sopenharmony_ci 1342141cc406Sopenharmony_cistatic SANE_Status 1343141cc406Sopenharmony_ciscsi_read_image(Microtek2_Scanner *, uint8_t *, int); 1344141cc406Sopenharmony_ci 1345141cc406Sopenharmony_cistatic SANE_Status 1346141cc406Sopenharmony_ciscsi_read_image_info(Microtek2_Scanner *); 1347141cc406Sopenharmony_ci 1348141cc406Sopenharmony_cistatic SANE_Status 1349141cc406Sopenharmony_ciscsi_read_image_status(Microtek2_Scanner *); 1350141cc406Sopenharmony_ci 1351141cc406Sopenharmony_cistatic SANE_Status 1352141cc406Sopenharmony_ciscsi_read_system_status(Microtek2_Device *, int); 1353141cc406Sopenharmony_ci 1354141cc406Sopenharmony_ci/* currently not used */ 1355141cc406Sopenharmony_ci/* static SANE_Status 1356141cc406Sopenharmony_ciscsi_request_sense(Microtek2_Scanner *); */ 1357141cc406Sopenharmony_ci 1358141cc406Sopenharmony_cistatic SANE_Status 1359141cc406Sopenharmony_ciscsi_send_gamma(Microtek2_Scanner *); 1360141cc406Sopenharmony_ci 1361141cc406Sopenharmony_cistatic SANE_Status 1362141cc406Sopenharmony_ciscsi_send_shading(Microtek2_Scanner *, uint8_t *, uint32_t, uint8_t); 1363141cc406Sopenharmony_ci 1364141cc406Sopenharmony_cistatic SANE_Status 1365141cc406Sopenharmony_ciscsi_read_shading(Microtek2_Scanner *, uint8_t *, uint32_t); 1366141cc406Sopenharmony_ci 1367141cc406Sopenharmony_cistatic SANE_Status 1368141cc406Sopenharmony_ciscsi_send_system_status(Microtek2_Device *, int); 1369141cc406Sopenharmony_ci 1370141cc406Sopenharmony_cistatic SANE_Status 1371141cc406Sopenharmony_ciscsi_sense_handler (int, u_char *, void *); 1372141cc406Sopenharmony_ci 1373141cc406Sopenharmony_cistatic SANE_Status 1374141cc406Sopenharmony_ciscsi_test_unit_ready(Microtek2_Device *); 1375141cc406Sopenharmony_ci 1376141cc406Sopenharmony_cistatic SANE_Status 1377141cc406Sopenharmony_ciscsi_set_window(Microtek2_Scanner *, int); 1378141cc406Sopenharmony_ci 1379141cc406Sopenharmony_cistatic SANE_Status 1380141cc406Sopenharmony_ciscsi_wait_for_image(Microtek2_Scanner *); 1381141cc406Sopenharmony_ci 1382141cc406Sopenharmony_ci#endif 1383