1 /* sane - Scanner Access Now Easy. 2 Copyright (C) 1996, 1997 David Mosberger-Tang 3 Copyright (C) 1997 R.E.Wolff@BitWizard.nl 4 5 This file is part of the SANE package. 6 7 This program is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the 10 License, or (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, but 13 WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <https://www.gnu.org/licenses/>. 19 20 */ 21 22 #ifndef tamarack_h 23 #define tamarack_h 24 25 #include <sys/types.h> 26 27 #define TAMARACK_FLAG_TA (1 << 3) /* transparency adapter */ 28 29 30 enum Tamarack_Option 31 { 32 OPT_NUM_OPTS = 0, 33 34 OPT_MODE_GROUP, 35 OPT_MODE, 36 #define OPT_MODE_DEFAULT 2 37 OPT_RESOLUTION, 38 #define OPT_RESOLUTION_DEFAULT 100 39 #if 0 40 OPT_SPEED, 41 OPT_SOURCE, 42 OPT_BACKTRACK, 43 #endif 44 OPT_PREVIEW, 45 OPT_GRAY_PREVIEW, 46 47 OPT_GEOMETRY_GROUP, 48 OPT_TL_X, /* top-left x */ 49 OPT_TL_Y, /* top-left y */ 50 OPT_BR_X, /* bottom-right x */ 51 OPT_BR_Y, /* bottom-right y */ 52 53 OPT_ENHANCEMENT_GROUP, 54 OPT_TRANS, 55 OPT_BRIGHTNESS, 56 OPT_CONTRAST, 57 OPT_THRESHOLD, 58 #if 0 59 OPT_CUSTOM_GAMMA, /* use custom gamma tables? */ 60 /* The gamma vectors MUST appear in the order gray, red, green, 61 blue. */ 62 OPT_GAMMA_VECTOR, 63 OPT_GAMMA_VECTOR_R, 64 OPT_GAMMA_VECTOR_G, 65 OPT_GAMMA_VECTOR_B, 66 67 OPT_HALFTONE_DIMENSION, 68 OPT_HALFTONE_PATTERN, 69 #endif 70 71 /* must come last: */ 72 NUM_OPTIONS 73 }; 74 75 76 77 typedef struct Tamarack_Device 78 { 79 struct Tamarack_Device *next; 80 SANE_Device sane; 81 SANE_Range dpi_range; 82 SANE_Range x_range; 83 SANE_Range y_range; 84 unsigned flags; 85 } 86 87 Tamarack_Device; 88 89 typedef struct Tamarack_Scanner 90 { 91 /* all the state needed to define a scan request: */ 92 struct Tamarack_Scanner *next; 93 94 SANE_Option_Descriptor opt[NUM_OPTIONS]; 95 Option_Value val[NUM_OPTIONS]; 96 SANE_Int gamma_table[4][256]; 97 #if 0 98 SANE_Int halftone_pattern[64]; 99 #endif 100 101 int scanning; 102 int pass; /* pass number */ 103 int line; /* current line number */ 104 SANE_Parameters params; 105 106 /* Parsed option values and variables that are valid only during 107 actual scanning: */ 108 int mode; 109 #if 0 110 int one_pass_color_scan; 111 int resolution_code; 112 #endif 113 int fd; /* SCSI filedescriptor */ 114 SANE_Pid reader_pid; /* process id of reader */ 115 int pipe; /* pipe to reader process */ 116 int reader_pipe; /* pipe from reader process */ 117 118 /* scanner dependent/low-level state: */ 119 Tamarack_Device *hw; 120 121 #if 0 122 /* line-distance correction related state: */ 123 struct 124 { 125 int max_value; 126 int peak_res; 127 struct 128 { 129 int dist; /* line distance */ 130 int Qk; 131 } 132 c[3]; 133 /* these are used in the MLD_MFS mode only: */ 134 char *red_buf; 135 char *green_buf; 136 } 137 ld; 138 #endif 139 } 140 Tamarack_Scanner; 141 142 143 144 #define TAM_ADF_ON 0x80 145 #define TAM_DOUBLE_ON 0x40 146 #define TAM_TRANS_ON 0x20 147 148 #define TAM_INVERSE_ON 0x20 149 150 151 152 153 #define THRESHOLDED 0 154 #define DITHERED 1 155 #define GREYSCALE 2 156 #define TRUECOLOR 3 157 158 159 160 /* Some Tamarack driver internal defines */ 161 #define WINID 0 162 163 164 /* SCSI commands that the Tamarack scanners understand: */ 165 166 #define TAMARACK_SCSI_TEST_UNIT_READY 0x00 167 #define TAMARACK_SCSI_INQUIRY 0x12 168 #define TAMARACK_SCSI_MODE_SELECT 0x15 169 #define TAMARACK_SCSI_START_STOP 0x1b 170 #define TAMARACK_SCSI_AREA_AND_WINDOWS 0x24 171 #define TAMARACK_SCSI_READ_SCANNED_DATA 0x28 172 #define TAMARACK_SCSI_GET_DATA_STATUS 0x34 173 174 175 /* The structures that you have to send to the tamarack to get it to 176 do various stuff... */ 177 178 struct win_desc_header { 179 unsigned char pad0[6]; 180 unsigned char wpll[2]; 181 }; 182 183 184 struct win_desc_block { 185 unsigned char winid; 186 unsigned char pad0; 187 unsigned char xres[2]; 188 unsigned char yres[2]; 189 unsigned char ulx[4]; 190 unsigned char uly[4]; 191 unsigned char width[4]; 192 unsigned char length[4]; 193 unsigned char brightness; 194 unsigned char thresh; 195 unsigned char contrast; 196 unsigned char image_comp; 197 unsigned char bpp; 198 unsigned char halftone[2]; 199 unsigned char pad_type; 200 unsigned char exposure; 201 unsigned char pad3; 202 unsigned char compr_type; 203 unsigned char pad4[5]; 204 }; 205 206 207 208 struct command_header { 209 unsigned char opc; 210 unsigned char pad0[3]; 211 unsigned char len; 212 unsigned char pad1; 213 }; 214 215 216 struct command_header_10 { 217 unsigned char opc; 218 unsigned char pad0[5]; 219 unsigned char len[3]; 220 unsigned char pad1; 221 }; 222 223 224 225 226 struct def_win_par { 227 struct command_header_10 dwph; 228 struct win_desc_header wdh; 229 struct win_desc_block wdb; 230 }; 231 232 233 struct page_header{ 234 char pad0[4]; 235 char code; 236 char length; 237 }; 238 239 240 241 struct tamarack_page { 242 char gamma; 243 unsigned char thresh; 244 unsigned char masks; 245 char delay; 246 char features; 247 char pad0; 248 }; 249 250 251 /* set SCSI highended variables. Declare them as an array of chars */ 252 /* endianness-safe, int-size safe... */ 253 #define set_double(var,val) var[0] = ((val) >> 8) & 0xff; \ 254 var[1] = ((val) ) & 0xff; 255 256 #define set_triple(var,val) var[0] = ((val) >> 16) & 0xff; \ 257 var[1] = ((val) >> 8 ) & 0xff; \ 258 var[2] = ((val) ) & 0xff; 259 260 #define set_quad(var,val) var[0] = ((val) >> 24) & 0xff; \ 261 var[1] = ((val) >> 16) & 0xff; \ 262 var[2] = ((val) >> 8 ) & 0xff; \ 263 var[3] = ((val) ) & 0xff; 264 265 #endif /* tamarack_h */ 266